Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 12 Aug 2020 14:57:08 +0200
From: Nikita Popov <nikita.ppv@...il.com>
To: musl@...ts.openwall.com
Subject: Re: strftime %Z behavior with manually populated struct tm

> I haven't checked, but I believe most implementations just print the
> zone name from the current timezone, using tm_isdst to decide whether
> to print the standard or daylight version of the name. This is
> insufficient with zoneinfo for zones where the name changed over time,
> where it would print the wrong name for historical times. So instead
> we support printing any one of the zone names from the current zone,
> if the tm_zone member points to one of them, and blank otherwise.

You are right. I was under the impression that glibc uses tm_zone, but
double checking the implementation right now, it doesn't. So the behavioral
discrepancy here comes from the fact that musl checks tm_zone at all, not
the other way around. Sorry for looking in the completely wrong direction
here.

> I think you have the wrong commit link; that one does not look
> related. If you have the real one I'd be interested in seeing what
> they did.

Indeed, I meant to link to
https://github.com/python/cpython/commit/5633c4f342d957df2ef0d67b9bfb472a0d28a76b.
What Python does is to retrieve musl's string for UTC using gmtime_r, as
well as trying to match against the current tzname.

> I think if applications want to use zones other than the actual
> configured zone with strftime, they need to just do something like
> expand the %Z themselves with the string they want before calling
> strftime (note: this requires quoting any % in the name).

With your explanation in mind, explicitly expanding %Z does seem like a
good approach. I'll consider doing that.

> I looked
> hard for a better solution that wouldn't crash valid applications, and
> couldn't find one at the time.

Possibly it would make sense to fall back to using the current tzname if
the pointer given in tm_zone is invalid, rather than an empty string?

Regards,
Nikita

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.