Class: TpCommon::Timezones::Zone
- Inherits:
-
Object
- Object
- TpCommon::Timezones::Zone
- Defined in:
- lib/tp_common/timezones/zone.rb
Constant Summary collapse
- SECONDS_IN_AN_HOUR =
3600- DAY_LIGHT_SAVING_ZONES =
['Etc/GMT+9', 'Etc/GMT+8', 'Etc/GMT+7', 'Etc/GMT+6', 'Etc/GMT+5'].freeze
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #date ⇒ Object
-
#initialize(time, key, name, title) ⇒ Zone
constructor
A new instance of Zone.
- #offset ⇒ Object
Constructor Details
#initialize(time, key, name, title) ⇒ Zone
Returns a new instance of Zone.
9 10 11 12 13 14 |
# File 'lib/tp_common/timezones/zone.rb', line 9 def initialize(time, key, name, title) @name = name @key = key @time = time @title = title end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/tp_common/timezones/zone.rb', line 7 def key @key end |
Instance Method Details
#date ⇒ Object
27 28 29 |
# File 'lib/tp_common/timezones/zone.rb', line 27 def date gmt_12.to_date end |
#offset ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tp_common/timezones/zone.rb', line 16 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 |