Class Time
In: lib/json/add/core.rb
Parent: Object
Range Date Time Exception Regexp Struct DateTime dot/f_6.png

Methods

Public Class methods

[Source]

    # File lib/json/add/core.rb, line 11
11:   def self.json_create(object)
12:     if usec = object.delete('u') # used to be tv_usec -> tv_nsec
13:       object['n'] = usec * 1000
14:     end
15:     if instance_methods.include?(:tv_nsec)
16:       at(object['s'], Rational(object['n'], 1000))
17:     else
18:       at(object['s'], object['n'] / 1000)
19:     end
20:   end

Public Instance methods

[Source]

    # File lib/json/add/core.rb, line 22
22:   def to_json(*args)
23:     nanoseconds = [ tv_usec * 1000 ]
24:     respond_to?(:tv_nsec) and nanoseconds << tv_nsec
25:     nanoseconds = nanoseconds.max
26:     {
27:       'json_class' => self.class.name,
28:       's' => tv_sec,
29:       'n' => nanoseconds,
30:     }.to_json(*args)
31:   end

[Validate]