public
Last active

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
diff --git a/src/org/jruby/RubyTime.java b/src/org/jruby/RubyTime.java
index d41a491..57f7f3c 100644
--- a/src/org/jruby/RubyTime.java
+++ b/src/org/jruby/RubyTime.java
@@ -1102,6 +1102,16 @@ public class RubyTime extends RubyObject {
public static RubyTime load(IRubyObject recv, IRubyObject from, Block block) {
return s_mload(recv, (RubyTime)(((RubyClass)recv).allocate()), from);
}
+
+ @JRubyMethod(name = {"timestamp", "current_timestamp"}, meta = true)
+ public static IRubyObject timestamp(ThreadContext context) {
+ return context.runtime.newFixnum(System.currentTimeMillis() / 1000);
+ }
+
+ @JRubyMethod(meta = true)
+ public static IRubyObject microtime(ThreadContext context) {
+ return context.runtime.newFloat(System.currentTimeMillis() / 1000.0);
+ }
@Override
public Object toJava(Class target) {

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.