Class: Time

Inherits:
Object show all
Defined in:
lib/crazy_ivan/vendor/json-1.1.7/lib/json/add/core.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.json_create(object) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/crazy_ivan/vendor/json-1.1.7/lib/json/add/core.rb', line 11

def self.json_create(object)
  if usec = object.delete('u') # used to be tv_usec -> tv_nsec
    object['n'] = usec * 1000
  end
  if respond_to?(:tv_nsec)
    at(*object.values_at('s', 'n'))
  else
    at(object['s'], object['n'] / 1000)
  end
end

Instance Method Details

#to_json(*args) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/crazy_ivan/vendor/json-1.1.7/lib/json/add/core.rb', line 22

def to_json(*args)
  {
    'json_class' => self.class.name,
    's' => tv_sec,
    'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000
  }.to_json(*args)
end