diff options
author | Florian Frank <flori@ping.de> | 2012-05-10 01:48:26 +0200 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2012-05-10 01:48:26 +0200 |
commit | 2797901a526a5bc95167c7eedd6d19a39b7a2ce9 (patch) | |
tree | 0fabb7bf6b42d85d084fb0ea3e16061e86e16424 | |
parent | 553b9b499fe7396b509fd607221d8c0ada8df67b (diff) | |
download | json-2797901a526a5bc95167c7eedd6d19a39b7a2ce9.tar.gz |
Work around jruby's inconsistent Time implement.
-rw-r--r-- | lib/json/add/time.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/json/add/time.rb b/lib/json/add/time.rb index 9755707..338209d 100644 --- a/lib/json/add/time.rb +++ b/lib/json/add/time.rb @@ -20,10 +20,13 @@ class Time # Returns a hash, that will be turned into a JSON object and represent this # object. def as_json(*) + nanoseconds = [ tv_usec * 1000 ] + respond_to?(:tv_nsec) and nanoseconds << tv_nsec + nanoseconds = nanoseconds.max { JSON.create_id => self.class.name, 's' => tv_sec, - 'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000 + 'n' => nanoseconds, } end |