timestamp 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/ext/timestamp/Timestamp.c +24 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87727f69d7ba11cdc52c27a1c150730806402a0d
4
- data.tar.gz: 4ac070bc75d8891c1a3871282d9f241de96f6057
3
+ metadata.gz: fad73a196958d666f5bab820ab2079d733273915
4
+ data.tar.gz: 8802615c4538ae3fac8a6552449e160db3a23728
5
5
  SHA512:
6
- metadata.gz: 01a39507bbee1925a209ab243f2227125ff5b919b9ba944742b0ed1b3e6a77267638e39a294dbf0e7bb719a3bd092c43dba242034bdd854ec7856744290003d2
7
- data.tar.gz: 78945ed73f03e5aa91202560e07ef065775f2ebc47a12e2227dab25bcaa296a8b897ac750526d6230776b9617137f301d17a2d0889a242e599300e071df7509d
6
+ metadata.gz: a4582283b0d921b1942b029637d618c0b22c0a8e1a008a587b23d8bdbb32af34f6366dad9d1fcfe69bbfc6c1e8e967b7f2bdf38cdd3264aefb29b9abdcd4963d
7
+ data.tar.gz: 497584ec3c6169d9640610969ed1f96a8921ecfaf1653c0b443a195191e885ba0cd096c2233c642c17ea445a0b5e0e91ef2d8c5de629aa3681c51afdbd2dad45
@@ -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
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timestamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Kerwin