mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com, Jan V??el?k <jan.vcelak@nic.cz>
Subject: Re: strptime() lacks support for %z
Date: Fri, 14 Aug 2015 17:08:23 +0200	[thread overview]
Message-ID: <20150814150823.GG27440@port70.net> (raw)
In-Reply-To: <20150814150038.GF27440@port70.net>

* Szabolcs Nagy <nsz@port70.net> [2015-08-14 17:00:39 +0200]:
> * Rich Felker <dalias@libc.org> [2015-08-14 10:15:40 -0400]:
> > On Fri, Aug 14, 2015 at 11:34:32AM +0200, Szabolcs Nagy wrote:
> > > * Jan V??el?k <jan.vcelak@nic.cz> [2015-08-14 10:00:23 +0200]:
> > > > On Thursday, August 13, 2015 10:06:50 PM Szabolcs Nagy wrote:
> > > > > the problem with parsing timezones is that it's not posix
> > > > > so the desired semantics is not clear (struct tm has no
> > > > > tz field in posix and it is not obvious how that should
> > > > > be treated in other apis that use struct tm.. glibc does
> > > > > something but it should be verified to give consistent
> > > > > behaviour if we add this to musl and there might be parsing
> > > > > corner cases when %z is not surrounded by spaces..).
> > > > 
> > > > I know it's not specified in POSIX strptime, however it is specified in 
> > > > strftime. I'm not sure how strictly do you want to stick to POSIX, but it 
> > > > seems reasonable to me to have the equivalent format support in both 
> > > > functions, so you can write the time stamp and parse it back.
> > > > 
> > > > Anyway, the format in strftime is simple and on fixed width, +hhmm or -hhmm.
> > > > 
> > > 
> > > strftime uses tzset (timezone from TZ) but strptime cannot
> > > set TZ so it must put the timezone somewhere else.
> > > 
> > > so strptime can't be consistent with strftime.
> > > with tz in struct tm, mktime/localtime no longer roundtrip.
> > 
> > I don't follow. strftime uses the extended fields from struct tm. I
> > don't see anywhere it depends on tzset, nor reasons why strptime would
> > need tzset to be called. Am I missing something?
> > 
> 
> it seems %z does not use it in musl, %Z does
> 
> __tm_to_tzname calls do_tzset()
> 
> posix says
> "Local timezone information is used as though strftime() called tzset()"

ah ok, the tz name and offset are independent

i expected both of those would be used from TZ in
strftime, but musl already uses the tm struct offset.

then implementing %z in strptime is less intrusive
than i thought.


  reply	other threads:[~2015-08-14 15:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13 18:56 Jan Včelák
2015-08-13 20:06 ` Szabolcs Nagy
2015-08-14  8:00   ` Jan Včelák
2015-08-14  9:34     ` Szabolcs Nagy
2015-08-14 14:05       ` Jan Včelák
2015-08-14 14:15       ` Rich Felker
2015-08-14 15:00         ` Szabolcs Nagy
2015-08-14 15:08           ` Szabolcs Nagy [this message]
2015-08-14 15:39             ` Rich Felker
2015-08-14  1:50 ` 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=20150814150823.GG27440@port70.net \
    --to=nsz@port70.net \
    --cc=jan.vcelak@nic.cz \
    --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).