[tz] Precise meaning of FROM and TO in a rule

Jon Skeet skeet at pobox.com
Mon Jul 7 20:38:19 UTC 2014

```Sorry to be pedantic again, but I'm trying to get my head round some fiddly
code, and I've come across an interesting bit of ambiguity.

FROM and TO are described <http://www.ietf.org/timezones/code/zic.8.txt>
like this:

FROM Gives the first year in which the rule applies. Any integer
> year can be supplied; the Gregorian calendar is assumed. The
> word minimum (or an abbreviation) means the minimum year
> representable as an integer. The word maximum (or an
> abbreviation) means the maximum year representable as an
> integer. Rules can describe times that are not representable
> as time values, with the unrepresentable times ignored; this
> allows rules to be portable among hosts with differing time
> value types.

TO Gives the final year in which the rule applies. In addition to
> minimum and maximum (as above), the word only (or an
> abbreviation) may be used to repeat the value of the FROM
> field.

It's not clear whether that "year" is:

1. The year in UTC at the transition
2. The year in the local time before the transition
3. The year in the local time after the transition
4. The year in the same frame of reference as the "AT" part

Option 1 seems unlikely.

Options 2 and 3 seem likely to be equivalent in all realistic time zones -
it would be odd for a time zone to add an hour of DST at 11.30pm on
December 31st, for example... and even odder for it to *subtract* an hour
of DST at 00.30am on January 1st.

Option 4 is tricky. In some ways it feels natural - if you're going to use
one frame of reference for a time, why not do it for the date as well? On
the other hand, it means that a "TO" value of (say) 2001 where the
transition is at 2am UTC on January 1st in a time zone with a standard time
of UTC+8 would actually have its last transition in 2000 local time,
assuming I've got my maths right.

Can I assume that one of option 2 or option 3 is intended, and that no
sensible time zone will ever make those two options behave differently?

I've tried reading the C source code, but given the subtleties involved,
I'd rather trust a natural language description. If we can come to a