Eric Brine wrote:
>Given a date and time zone, is it possible to obtain the first time of that
>date?

Given standard APIs for time conversion, I'd perform a binary search
among UT times, converting them to the zone's local time and looking
for the threshold at which the local date changes.  The result of the
conversion at the threshold time includes a local time-of-day that should
be the one you're after.

This search approach assumes that all the UT times associated with a
particular local date are contiguous, which I think is the case throughout
the database, even in extreme cases.  (The most extreme cases are zones
such as America/Anchorage that crossed the IDL from a positive UT offset
to negative, yielding a period of 48 consecutive hours associated with a
single calendar day in local time.  Though in the specific case of Alaska
the single calendar day is conventionally described using different
calendars for the two halves of that 48-hour period.)

Another type of edge case also might matter, depending on what you
mean by "the first time of that date".  If you actually want the local
time-of-day at the beginning of the calendar day, that's fine.  But if
you actually want the lowest local time-of-day that occurs at any time
during the calendar day, you could in principle be misled by a zone that
jumps forward at midnight and then back slightly later (say, forward an
hour at local 00:00->01:00, then back an hour at local 01:30->00:30).
I think this also doesn't occur anywhere in the database.

-zefram

Reply via email to