Skip to content

Instantly share code, notes, and snippets.

@headius
Last active December 16, 2015 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save headius/5393552 to your computer and use it in GitHub Desktop.
Save headius/5393552 to your computer and use it in GitHub Desktop.
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) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment