timestamp 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/ext/timestamp/Timestamp.c +24 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fad73a196958d666f5bab820ab2079d733273915
|
4
|
+
data.tar.gz: 8802615c4538ae3fac8a6552449e160db3a23728
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4582283b0d921b1942b029637d618c0b22c0a8e1a008a587b23d8bdbb32af34f6366dad9d1fcfe69bbfc6c1e8e967b7f2bdf38cdd3264aefb29b9abdcd4963d
|
7
|
+
data.tar.gz: 497584ec3c6169d9640610969ed1f96a8921ecfaf1653c0b443a195191e885ba0cd096c2233c642c17ea445a0b5e0e91ef2d8c5de629aa3681c51afdbd2dad45
|
data/ext/timestamp/Timestamp.c
CHANGED
@@ -19,7 +19,31 @@ time_s_current_timestamp(VALUE klass)
|
|
19
19
|
return INT2NUM( time(NULL) );
|
20
20
|
}
|
21
21
|
|
22
|
+
/*
|
23
|
+
* call-seq:
|
24
|
+
* Time.microtime -> float
|
25
|
+
*
|
26
|
+
* Returns the current time as a floating-point number of seconds
|
27
|
+
* since the Epoch.
|
28
|
+
*
|
29
|
+
* Time.microtime #=> 1363352771.315240
|
30
|
+
*/
|
31
|
+
|
32
|
+
static VALUE
|
33
|
+
time_s_microtime(VALUE klass)
|
34
|
+
{
|
35
|
+
struct timeval tv;
|
36
|
+
double t;
|
37
|
+
if (gettimeofday(&tv, 0) < 0) {
|
38
|
+
rb_sys_fail("gettimeofday");
|
39
|
+
}
|
40
|
+
t = (double)tv.tv_sec;
|
41
|
+
t += ((double)tv.tv_usec / 1000000.0);
|
42
|
+
return rb_float_new(t);
|
43
|
+
}
|
44
|
+
|
22
45
|
void Init_timestamp() {
|
23
46
|
rb_define_singleton_method(rb_cTime, "current_timestamp", time_s_current_timestamp, 0);
|
24
47
|
rb_define_singleton_method(rb_cTime, "timestamp", time_s_current_timestamp, 0);
|
48
|
+
rb_define_singleton_method(rb_cTime, "microtime", time_s_microtime, 0);
|
25
49
|
}
|