Re: Algorithm to exploit 32 bit time functions to do time zone calculations
Thorsten Glaser <[email protected]> Wed, 17 Sep 2008 09:28:02 +0000 (UTC)
| Newsgroups | gmane.os.miros.general,gmane.comp.lib.libtai |
|---|---|
| Message-ID | <[email protected]> |
Michael G Schwern dixit: >>> If I understand correctly, that's an entire operating system. >>=20 >> Yes, but the gist is, that there is code which uses a certain 64-bit typ= e, >> called time_t, but you could of course just use int64_t instead, which d= oes >> the job quite fine. (Not even a binary change in the time zone data form= at.) > >Is this approach portable outside BSD? > >My main targets are Perl, Python and Ruby which have to be absurdly portab= le. > As I understand it, almost nothing about the time zone database is portab= le. Oh, okay. This is a step further away from Unix. > For example, I could not expect tzload() to work on all operating systems= =2E I >would have to ship my own, which I do not want to do, or write time zone c= ode >for each operating system, which I also do not want to do. You probably could just take the entire Olson time library in its original, portable state, and change that. (This would have the beneficial side effec= t to replace vendors=E2=80=99 probably buggier time libraries and time zone d= atabases with something known to work.) But I like your =E2=80=9Cwrapping=E2=80=9D a= pproach. >In fact, I'm considering changing from >MIT to BSD license to make that even easier. There is not a single BSD licence. MIT is just fine=E2=80=A6 OpenBSD uses I= SC for new code, and, being European, MirBSD has to have its own only slightly different one too ;) >Speaking of asctime(), I think this is a y2**31 bug in asctime3: > >=09char=09=09=09year[INT_STRLEN_MAXIMUM(int) + 2]; Yup, probably. >Oh, don't forget to make tm.tm_year 64 bit! Yeah, that bites us great time. For example, look here: http://cvs.mirbsd.de/ports/lang/python/2.5/patches/patch-Modules_datetimemo= dule_c When you have only one of the two chunks, it dumps core. Takes a while to find it, since -Wformat did not, obviously, catch this case. It usually spots all occurrences though. >Anyhow, if you're interested in the Test Anything Protocol, a really simpl= e I implemented it in Python for the day-job project I'm currently working on, since my colleague is a Perl fan=E2=80=A6 but thanks ;) 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"