1
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
6
# DateTime serialization/deserialization
9
# Deserializes JSON string by converting year <tt>y</tt>, month <tt>m</tt>,
10
# day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
11
# offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> to DateTime.
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)
24
alias start sg unless method_defined?(:start)
26
# Returns a hash, that will be turned into a JSON object and represent this
30
JSON.create_id => self.class.name,
42
# Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
43
# day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
44
# offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
46
as_json.to_json(*args)