Module: Philiprehberger::CronKit::Timezone
- Defined in:
- lib/philiprehberger/cron_kit/timezone.rb
Overview
Converts timezone identifiers to UTC offsets using only stdlib.
Supports: “UTC”, fixed offsets (“+05:00”, “-04:00”), and common POSIX timezone names (e.g., “US/Eastern”, “Europe/London”) via ENV.
Class Method Summary collapse
-
.apply(time, offset_seconds) ⇒ Object
Convert a Time to the equivalent moment in the given timezone offset (seconds).
-
.utc_offset_for(timezone) ⇒ Object
Resolve a timezone identifier to a UTC offset in seconds.
Class Method Details
.apply(time, offset_seconds) ⇒ Object
Convert a Time to the equivalent moment in the given timezone offset (seconds).
18 19 20 |
# File 'lib/philiprehberger/cron_kit/timezone.rb', line 18 def self.apply(time, offset_seconds) Time.new(time.year, time.month, time.day, time.hour, time.min, time.sec, offset_seconds) end |
.utc_offset_for(timezone) ⇒ Object
Resolve a timezone identifier to a UTC offset in seconds.
11 12 13 14 15 |
# File 'lib/philiprehberger/cron_kit/timezone.rb', line 11 def self.utc_offset_for(timezone) return nil if timezone.nil? try_utc(timezone) || try_numeric_offset(timezone) || probe_offset(timezone) end |