http://qs1969.pair.com?node_id=222003


in reply to Playing with time (or, a lament to POSIX::strftime's %Z)

As waswas-fng explains, this problem is much harder than it first appears. To the best of my knowledge, there is no strictly algorithmic way to compute the local time correctly for any arbitrary place on earth. In some countries, e.g. Israel, the start and end dates of daylight savings time are not directly computable, because they are decided upon each year by some sort of panel (though I suppose you could watch for their announcements and update your lookup tables). In other cases locations that do have "rules" for daylight savings time bend those rules because of special events.

That's on top of the fact that individual countries may begin and end daylight savings time at different points in the year (and don't forget that summer and winter in the southern hemisphere are opposite what they are in the northern)... and begin and end dst at different times during the night (e.g. 1am vs. 2am). Oh, and there are some really arcane rules within countries as well. In the U.S. for example, Hawaii and Arizona don't observe dst, except for the portion of Arizona that is part of the Navajo reservation, which does. In Indiana, different counties are in different times zones; some observe dst, and some don't. There's some underlying logic to it, but without knowing precisely where a user is located relative to a basically arbitrary line on a map, you're going to have a tough time working it all out!

(And in the way-OT department, here's my personal rant about time, since you asked: the Washington State Ferry schedule reads, "Noon is noted as 12:00 a.m. and one minute past noon as 12:01 p.m.; midnight is noted as 12:00 p.m. and one past midnight as 12:01 a.m." Isn't the opposite the way virtually everyone else in the world handles noon and midnight?)

        $perlmonks{seattlejohn} = 'John Clyman';