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
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.
8 9 10 11 12 13 |
# File 'lib/tp_common/timezones/zone.rb', line 8 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.
6 7 8 |
# File 'lib/tp_common/timezones/zone.rb', line 6 def key @key end |
Instance Method Details
#date ⇒ Object
26 27 28 |
# File 'lib/tp_common/timezones/zone.rb', line 26 def date gmt_12.to_date end |
#offset ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# 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 |