mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: strftime %Z returning empty string
Date: Thu, 31 Aug 2017 17:56:53 -0400	[thread overview]
Message-ID: <20170831215653.GI1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <alpine.DEB.2.00.1708311702130.12602@ny1.eemta.org>

On Thu, Aug 31, 2017 at 05:12:23PM -0400, jacob@welshcomputing.com wrote:
> On Thu, 31 Aug 2017, A. Wilcox wrote:
> 
> >%Z is a glibc extension.  I don't believe musl supports it.
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html
> 
>     Z       Replaced by the timezone name or abbreviation, or by no bytes
>             if no timezone information exists. [tm_isdst]
> 
> That "if no timezone information exists" is rather useless in my
> eyes. Exists where? Later text suggests that the TZ environment
> variable is relevant.

In order for %Z to reliably be able to print something meaningful, the
struct tm must contain the extension field tm_zone reflecting the zone
to which it applies. Otherwise, there are at least two sources of
ambiguity: there's no indication whether the struct tm contains UTC or
local time, and in the latter case, tm_isdst is insufficient to
disambiguate a zone name, since the TZ (for zoneinfo style TZ) may
contain multiple different historical zones that apply to the
territory rather than just a single daylight and single normal zone
name.

The latter ambiguity could probably be dealt with by trying to
interpret the struct tm fields to obtain an absolute time, then
determine according to the current TZ what zone name was in effect at
that time. But this doesn't disambiguate UTC vs local time.

If further consideration of the issue by standards committees (mainly
Austin Group) determines that there is some behavior that should be
followed to resolve the ambiguity, even if it's not a very nice
behavior, I'll see what we can do in musl to conform to the standard.
But right now it's underspecified and there's really no way to get
meaningful information from a zero-filled struct tm.

Rich


  reply	other threads:[~2017-08-31 21:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-31 20:23 jacob
2017-08-31 20:44 ` A. Wilcox
2017-08-31 21:12   ` jacob
2017-08-31 21:56     ` Rich Felker [this message]
2017-09-01  8:57   ` Szabolcs Nagy
2017-09-04 23:27 ` musl's asctime catches Python bug jacob
2017-09-05  0:08   ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170831215653.GI1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).