Class: Time

Inherits:
Object show all
Defined in:
lib/fiveruns/json/add/core.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fjson_create(object) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/fiveruns/json/add/core.rb', line 7

def self.fjson_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_fjson(*args) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/fiveruns/json/add/core.rb', line 18

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