class TpCommon::Timezones::Zone
Constants
- SECONDS_IN_AN_HOUR
Attributes
key[R]
Public Class Methods
new(time, key, name, title)
click to toggle source
# File lib/tp_common/timezones/zone.rb, line 8 def initialize(time, key, name, title) @name = name @key = key @time = time @title = title end
Public Instance Methods
date()
click to toggle source
# File lib/tp_common/timezones/zone.rb, line 26 def date gmt_12.to_date end
offset()
click to toggle source
# File lib/tp_common/timezones/zone.rb, line 15 def offset base_offset = (time_difference_in_seconds / SECONDS_IN_AN_HOUR).abs zone = Time.find_zone(@title) if !zone.nil? && zone.parse(@time.to_date.to_s).dst? base_offset = base_offset - 1 end base_offset end
Private Instance Methods
gmt_12()
click to toggle source
# File lib/tp_common/timezones/zone.rb, line 32 def gmt_12 @time.in_time_zone('Etc/GMT-12') end
organization_time()
click to toggle source
# File lib/tp_common/timezones/zone.rb, line 36 def organization_time @time.in_time_zone(@name) end
time_difference_in_seconds()
click to toggle source
# File lib/tp_common/timezones/zone.rb, line 40 def time_difference_in_seconds gmt_12.utc_offset - organization_time.utc_offset end