summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/json/lib/json/add/time.rb11
1 files changed, 2 insertions, 9 deletions
diff --git a/ext/json/lib/json/add/time.rb b/ext/json/lib/json/add/time.rb
index 599ed9e24b..0ee9c9ed2c 100644
--- a/ext/json/lib/json/add/time.rb
+++ b/ext/json/lib/json/add/time.rb
@@ -10,11 +10,7 @@ class Time
if usec = object.delete('u') # used to be tv_usec -> tv_nsec
object['n'] = usec * 1000
end
- if method_defined?(:tv_nsec)
- at(object['s'], Rational(object['n'], 1000))
- else
- at(object['s'], object['n'] / 1000)
- end
+ at(object['s'], Rational(object['n'], 1000))
end
# Methods <tt>Time#as_json</tt> and +Time.json_create+ may be used
@@ -34,13 +30,10 @@ class Time
# # => 2023-11-25 11:00:56.472846644 -0600
#
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' => nanoseconds,
+ 'n' => tv_nsec,
}
end