Parent

Files

DateTime

DateTime serialization/deserialization

Public Class Methods

json_create(object) click to toggle source

Deserializes JSON string by converting year y, month m, day d, hour H, minute M, second S, offset of and Day of Calendar Reform sg to DateTime.

    # File lib/json/add/date_time.rb, line 12
12:   def self.json_create(object)
13:     args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
14:     of_a, of_b = object['of'].split('/')
15:     if of_b and of_b != '0'
16:       args << Rational(of_a.to_i, of_b.to_i)
17:     else
18:       args << of_a
19:     end
20:     args << object['sg']
21:     civil(*args)
22:   end

Public Instance Methods

as_json(*) click to toggle source

Returns a hash, that will be turned into a JSON object and represent this object.

    # File lib/json/add/date_time.rb, line 28
28:   def as_json(*)
29:     {
30:       JSON.create_id => self.class.name,
31:       'y' => year,
32:       'm' => month,
33:       'd' => day,
34:       'H' => hour,
35:       'M' => min,
36:       'S' => sec,
37:       'of' => offset.to_s,
38:       'sg' => start,
39:     }
40:   end
to_json(*args) click to toggle source

Stores class name (DateTime) with Julian year y, month m, day d, hour H, minute M, second S, offset of and Day of Calendar Reform sg as JSON string

    # File lib/json/add/date_time.rb, line 45
45:   def to_json(*args)
46:     as_json.to_json(*args)
47:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.