Module: CureLine::TimeMethods

Included in:
Post
Defined in:
lib/cure_line/time_methods.rb

Instance Method Summary collapse

Instance Method Details

#time_at(unixtime) ⇒ ActiveSupport::TimeWithZone, Time

Parameters:

  • unixtime (Integer)

Returns:

  • (ActiveSupport::TimeWithZone)

    When ‘Time.zone` is initialized

  • (Time)

    When ‘Time.zone` is not initialized or without activesupport



7
8
9
10
11
12
13
# File 'lib/cure_line/time_methods.rb', line 7

def time_at(unixtime)
  if Time.respond_to?(:zone) && Time.zone.respond_to?(:at)
    Time.zone.at(unixtime)
  else
    Time.at(unixtime)
  end
end