David Woodhouse wrote:
Eww. The time functions we have to play with _really_ suck, don't they?
How about this...
+ then += tm.tm_gmtoff;
tm_gmtoff is not available everywhere - POSIX doesn't even mention it (BSD?).
Oh btw, when we are about sucking time functions: the %s and %z strftime-
sequences used further down are also non-standard (POSIX has no %s, old
libc has neither %s nor %z).
A possible workaround:
void make_datestamp(char *buf)
{
time_t now;
struct tm *tm;
int tz;
time(&now);
tm = localtime(&now); /* get timezone and tm_isdst */
tz = -timezone / 60;
if (tm->tm_isdst > 0)
tz += 60;
sprintf(buf, "%lu %+05d", now, tz/60*100+tz%60);
}
That *should* work on any POSIX system but who knows ...
Ciao, ET.