[tz] [PROPOSED PATCH] port 'environ' decl to Solaris 10

Paul Eggert eggert at cs.ucla.edu
Mon Sep 5 01:03:38 UTC 2016


Random832 wrote:
> 1. Why exactly does this code do this instead of using setenv/putenv?

The code predates the standardization of setenv/putenv by POSIX. It manipulates 
'environ' directly for portability to pre-POSIX platforms. If we can assume 
setenv the code could be simplified.

> 2. Why mess with the environment at all instead of conditionally calling
> gmtime rather than localtime?

For zdump.c, calling gmtime doesn't suffice because zdump needs arbitrary time 
zones, not just localtime and gmtime.

For date.c, the shell command 'date -u +%Z' should output "GMT". Merely using 
gmtime+strftime does not suffice for that, because strftime is given a struct 
tm, which on some platforms does not contain a time zone abbreviation.



More information about the tz mailing list