|
|
|
|
|
by scottlamb
3400 days ago
|
|
There's another easy way to avoid this: use localtime_r instead of localtime. From the glibc source: /* Update internal database according to current TZ setting.
POSIX.1 8.3.7.2 says that localtime_r is not required to set tzname.
This is a good idea since this allows at least a bit more parallelism. */
tzset_internal (tp == &_tmbuf && use_localtime, 1);
mktime also does the tzset call every time, though: time_t
mktime (struct tm *tp)
{
#ifdef _LIBC
/* POSIX.1 8.1.1 requires that whenever mktime() is called, the
time zone names contained in the external variable 'tzname' shall
be set as if the tzset() function had been called. */
__tzset ();
#endif
and I don't see any way around that other than setting TZ=: or some such. |
|