NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/57588: gmtime(3): value of %s depends on TZ environment variable



The following reply was made to PR lib/57588; it has been noted by GNATS.

From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: lib/57588: gmtime(3): value of %s depends on TZ environment variable
Date: Sat, 19 Aug 2023 09:28:47 -0000 (UTC)

 roland.illig%gmx.de@localhost writes:
 
 >As documented in usr.bin/make/unit-tests/varmod-gmtime.mk 1.16 line 149, calling gmtime followed by strftime("%s") depends on the timezone, even though the timezone should not affect gmtime.
 
 >This bug does not affect date(1), as that utility always uses localtime(3) (for undocumented reasons) and rather sets the TZ environment variable instead of using gmtime(3).
 
 
 The problem is strftime. A standard struct tm doesn't have any information
 about the time zone, so to convert a struct tm back to UTC seconds strftime
 takes the local timezone. The %s format is not POSIX, our man page refers
 to ctime(3), Linux refers to mktime(3) to indicate this.
 
 strftime_z() lets you pass the missing information explicitely.
 


Home | Main Index | Thread Index | Old Index