Module: GBDate::String::Time

Included in:
String
Defined in:
lib/gb_date/string.rb

Instance Method Summary collapse

Instance Method Details

#in_time_zone(zone = ::Time.zone) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/gb_date/string.rb', line 13

def in_time_zone(zone = ::Time.zone)
  if zone && self =~ ::ActiveRecord::ConnectionAdapters::Column::Format::NUMERIC_TIME
    ::Time.find_zone!(zone).at(self.to_f)
  else
    super
  end
end

#to_timeObject



5
6
7
8
9
10
11
# File 'lib/gb_date/string.rb', line 5

def to_time
  if self =~ ::ActiveRecord::ConnectionAdapters::Column::Format::NUMERIC_TIME
    ::Time.at(self.to_f)
  else
    super
  end
end