Re: Algorithm to exploit 32 bit time functions to do time zone calculations
Thorsten Glaser <[email protected]> Wed, 17 Sep 2008 23:15:01 +0000 (UTC)
| Newsgroups | gmane.os.miros.general,gmane.comp.lib.libtai |
|---|---|
| Message-ID | <[email protected]> |
Michael G Schwern dixit: >>> Maybe you can shed some light on this problem, what to do about year 0? >>=20 >> I actually haven=E2=80=99t thought about year 0, since localtime/mktime = do that, >> and mjd2tm and tm2mjd from DJB code. I think it=E2=80=99s illegal, isn= =E2=80=99t it? > >Illegal according to who? > >C99 and POSIX 1003.1 define tm.tm_year as a signed int with a range of "ye= ars >since 1900" which makes a negative year perfectly "legal". 0 is not negative, and there has been no year 0, only 1 ante christo (-1) followed directly by 1 post christo. (Ironically, he was probably not born by then.) >I'm a little lost. Could you give an example? Yup. Convert -2=E2=81=B6=C2=B3 from time_t to TAI (while honouring leap sec= onds), and it will wrap, because the result would be -2=E2=81=B6=C2=B3-10 (plus the BI= AS), which is actually positive. But that doesn=E2=80=99t matter, as it wraps back on = the way back. So don=E2=80=99t introduce any arbitrary limits. >I wonder how a Chinese locale deals with this. They switched from Julian = to >Gregorian after 1901, so it should show up in any Chinese localtime() >implementation. Also Russia and much of Eastern Europe. I think a =E2=80=9Cstruct tm=E2=80=9D is just always gregorian, since other= calendars do not neccessarily have the same day/month/year concept (example: Japanese). >PPS How does one get the damn qsecretary program to stop making you confi= rm >every email to this list? I'm already subscribed. Same problem here. I think it uses the envelope address, not the header address, to check, which is, IMO, a bug in DJB=E2=80=99s mailing list softw= are =E2=98=BA bye, //mirabilos --=20 Sometimes they [people] care too much: pretty printers [and syntax highligh= - ting, d.A.] mechanically produce pretty output that accentuates irrelevant detail in the program, which is as sensible as putting all the prepositions in English text in bold font.=09-- Rob Pike in "Notes on Programming in C"