Module: TimeWithZonePatch
- Defined in:
- lib/dynamic_time_zone/time_with_zone_patch.rb
Instance Method Summary collapse
- #formatted_offset(*args) ⇒ Object
- #localtime(utc_offset = nil) ⇒ Object (also: #getlocal)
- #using_dynamic_time_zone? ⇒ Boolean
Instance Method Details
#formatted_offset(*args) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/dynamic_time_zone/time_with_zone_patch.rb', line 11 def formatted_offset(*args) actual_formatted_offset = super return actual_formatted_offset unless using_dynamic_time_zone? seconds_in_24_hours = 24 * 60 * 60 utc_offset.abs > seconds_in_24_hours ? '+0000' : actual_formatted_offset end |
#localtime(utc_offset = nil) ⇒ Object Also known as: getlocal
4 5 6 7 8 |
# File 'lib/dynamic_time_zone/time_with_zone_patch.rb', line 4 def localtime(utc_offset = nil) return super unless using_dynamic_time_zone? utc + (utc_offset || 0).seconds end |
#using_dynamic_time_zone? ⇒ Boolean
19 20 21 |
# File 'lib/dynamic_time_zone/time_with_zone_patch.rb', line 19 def using_dynamic_time_zone? DynamicTimeZone::Validator.new.valid?(time_zone.name) end |