[tz] Handling of uninitialized tm_gmtoff and tm_zone

Paul Eggert eggert at cs.ucla.edu
Thu Oct 2 23:00:17 UTC 2014


random832 at fastmail.us wrote:
> It is possible that mktime, strftime, etc?, may be called with a struct
> tm that has not had non-standard members initialized. How does tzcode
> deal with these cases? (It_looks_  like strftime handles it badly; I
> can't figure out what, if anything, the mktime implementation does with
> these members).

Do you have specific uses in mind?

In general, common practice often disagrees with a strict (perhaps overly 
strict?) reading of the standards here.  For example, glibc strftime also 
handles %Z "badly" in the sense that if a program calls strftime %Z with a 
struct tm that has not had tm_zone initialized properly, undefined behavior 
results.  In practice people seem to prefer glibc's behavior (which often 
results in more-accurate %Z output), and I'm inclined to think it's more a bug 
or lack-of-clarity in the standards than a bug in the implementations.


More information about the tz mailing list