 | | In order to write a function that converts UNIX time format to a date and time string representing local time, you have to keep track of a number of different things. First, you have to know what time zone you are in and how that time zone is offset from UTC. This means that the conversion is different depending on whether you're in New York City, Los Angeles, or Moscow. Furthermore, you have to know the rules for DST in this time zone; this is even more complicated. DST is determined differently in different parts of the world; some areas observe it, and some don't. Consider the United States' rules for DST observance. Prior to 1967, observance of DST was by local option except during World War I and II, when it was mandatory. Since 1967, DST has been observed by nearly the entire country. But even this has exceptions; the state of Indiana, with the exception of the northwest and southeast corners, does not observe DST. To further complicate matters, prior to 1987, DST began on the last Sunday in April; since 1987 it has begun on the first Sunday in April. DST ends on the last Sunday in October. This seems fairly straightforward. But in 1974 and 1975, because of the energy crisis, DST began on January 6 and February 23, respectively. And in 1989, the U.S. House of Representatives passed a bill that would make DST in the Pacific time zone end on the first Sunday after November 7th in presidential election years and on the last Sunday in October otherwise (this bill was never signed into law). | |
|