late 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.txt +2 -2
- data/ext/late/late.c +23 -1
- data/lib/late/version.rb +1 -1
- metadata +2 -2
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2013 Andrew De Ponte
|
1
|
+
Copyright (c) 2013 Andrew De Ponte, ReachLocal Inc.
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/ext/late/late.c
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
#include <ruby.h>
|
2
2
|
#include <time.h>
|
3
3
|
|
4
|
+
// Outputs Tue, 05 Mar 2013 16:58:29 GMT
|
5
|
+
const VALUE late_httpdate(VALUE self, VALUE rb_epoch) {
|
6
|
+
time_t epoch = FIX2LONG(rb_epoch);
|
7
|
+
struct tm * timeinfo;
|
8
|
+
char buffer[80];
|
9
|
+
timeinfo = gmtime(&epoch);
|
10
|
+
strftime(buffer, 80, "%a, %d %b %Y %H:%M:%S %Z", timeinfo);
|
11
|
+
return rb_str_new2(buffer);
|
12
|
+
}
|
13
|
+
|
14
|
+
const VALUE late_pp(VALUE self, VALUE rb_epoch, VALUE rb_format) {
|
15
|
+
time_t epoch = FIX2LONG(rb_epoch);
|
16
|
+
char * format = RSTRING_PTR(rb_format);
|
17
|
+
struct tm * timeinfo = gmtime(&epoch);
|
18
|
+
int buffer_length = RSTRING_LEN(rb_format) + 40;
|
19
|
+
char buffer[buffer_length];
|
20
|
+
timeinfo = gmtime(&epoch);
|
21
|
+
strftime(buffer, buffer_length, format, timeinfo);
|
22
|
+
return rb_str_new2(buffer);
|
23
|
+
}
|
24
|
+
|
4
25
|
/* our new native method; it just returns the seconds since epoch" */
|
5
26
|
static VALUE late_epoch(VALUE self) {
|
6
27
|
time_t current_time = time(NULL);
|
@@ -12,6 +33,7 @@ void Init_late(void) {
|
|
12
33
|
/* assume we haven't yet defined 'late' */
|
13
34
|
VALUE klass = rb_define_class("Late", rb_cObject);
|
14
35
|
|
15
|
-
/* the late_bonjour function can be called from ruby as Late.bonjour */
|
16
36
|
rb_define_singleton_method(klass, "epoch", late_epoch, 0);
|
37
|
+
rb_define_singleton_method(klass, "pp", late_pp, 2);
|
38
|
+
rb_define_singleton_method(klass, "httpdate", late_httpdate, 1);
|
17
39
|
}
|
data/lib/late/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: late
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Late is a gem that provides extremely fast C binding based time methods
|
15
15
|
email:
|