[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] timegm() considered harmful
From: |
John Cowan |
Subject: |
[Chicken-users] timegm() considered harmful |
Date: |
Sat, 29 Jul 2006 12:16:58 -0400 |
User-agent: |
Mutt/1.3.28i |
Chicken 2.41 still won't build on Solaris because there is no timegm()
function there; it's a GNU extension, and Solaris doesn't have a GNU libc.
A fallback implementation, currently used only on Cygwin, does appear
in posixunix.scm, but it doesn't work on Solaris 8 either because it
uses setenv() and unsetenv(), which do not exist there -- they were not
added to Posix until a later revision. I see two possibilities:
1) Remove timegm() references altogether, on the ground that the
function simply isn't Posix and doesn't belong in a Posix library.
The GNU C library documentation calls it "rarely available", that is,
unavailable except where GNU libc is the system libc.
2) Use a potentially inaccurate implementation like this:
int offset = gmtime() - localtime();
time_t result = mktime(blah, blah, blah ...);
return result + offset;
The danger here is that the gmtime() and localtime() calls could
occur in different seconds, thus causing the difference to be
off by 1 second most of the time, or by a much larger number
at a DST transition or change of time zone.
--
Don't be so humble. You're not that great. John Cowan
--Golda Meir address@hidden
- [Chicken-users] timegm() considered harmful,
John Cowan <=