Module: Rave::Mixins::TimeUtils

Included in:
Rave::Models::Blip, Rave::Models::Event, Rave::Models::Wavelet
Defined in:
lib/mixins/time_utils.rb

Instance Method Summary collapse

Instance Method Details

#time_from_json(time) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/mixins/time_utils.rb', line 5

def time_from_json(time)
  if time
    time_s = time.to_s
    epoch = if time_s.length > 10
      "#{time_s[0, 10]}.#{time_s[10..-1]}".to_f
    else
      time.to_i
    end
    Time.at(epoch)
  end
end