The native APIs don't support previous transition, only next after a
stipulated date. The prior code started its search at the epoch; if
used for a time before the first transition after the epoch, this
found no transitions so returned invalid data, when the last
transition before the epoch would have been suitable. It also wound
through all transitions since the epoch, on its way to the selected
time, which was potentially laborious.
Instead, start a year before the stipulated time; this should get a
transition if the zone uses DST. If it doesn't, start with the first
known transition and binary-chop our way to one within a year of the
last before the stipulated time; then wind forward one transition at a
time, as before. The chopping is actually faster than binary: each
time we find a transition after the interval mid-point but early
enough, we move the early end of our interval to the transition, which
is later than the old interval's middle. Using halving, starting with
a vast interval, should thus only incur modest cost, while ensuring we
give up early when no transition data is available at all or the
zone's first transition ever was after the stipulated time.
Change-Id: I96c14540fc2600837e6a22e480fb8dc36cb37220
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>