class TZInfo::DataSources::PosixTimeZoneParser
def parse_rule(s, type)
-
(TransitionRule)- the parsed rule.
Raises:
-
(InvalidPosixTimeZone)- if the rule is not valid.
Parameters:
-
type(String) -- the type of rule (either `'start'` or `'end'`). -
s(StringScanner) -- the `StringScanner` to read the rule from.
def parse_rule(s, type) check_scan(s, /,(?: (?: J(\d+) ) | (\d+) | (?: M(\d+)\.(\d)\.(\d) ) )/x) julian_day_of_year = s[1] absolute_day_of_year = s[2] month = s[3] week = s[4] day_of_week = s[5] if s.scan(/\//) check_scan(s, /([-+]?\d+)(?::(\d+)(?::(\d+))?)?/) transition_at = get_seconds_after_midnight_from_hms(s[1], s[2], s[3]) else transition_at = 7200 end begin if julian_day_of_year JulianDayOfYearTransitionRule.new(julian_day_of_year.to_i, transition_at) elsif absolute_day_of_year AbsoluteDayOfYearTransitionRule.new(absolute_day_of_year.to_i, transition_at) elsif week == '5' LastDayOfMonthTransitionRule.new(month.to_i, day_of_week.to_i, transition_at) else DayOfMonthTransitionRule.new(month.to_i, week.to_i, day_of_week.to_i, transition_at) end rescue ArgumentError => e raise InvalidPosixTimeZone, "Invalid #{type} rule in POSIX-style time zone string: #{e}" end end