Sept. 5, 2016
1:03 a.m.
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.