From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8300 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: strptime() lacks support for %z Date: Fri, 14 Aug 2015 17:08:23 +0200 Message-ID: <20150814150823.GG27440@port70.net> References: <55CCE86F.5060409@nic.cz> <20150813200649.GC27440@port70.net> <2866636.1jqx2TLbIl@pc-cznic4> <20150814093431.GD27440@port70.net> <20150814141540.GJ31018@brightrain.aerifal.cx> <20150814150038.GF27440@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1439564927 24415 80.91.229.3 (14 Aug 2015 15:08:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Aug 2015 15:08:47 +0000 (UTC) To: musl@lists.openwall.com, Jan V??el?k Original-X-From: musl-return-8312-gllmg-musl=m.gmane.org@lists.openwall.com Fri Aug 14 17:08:47 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZQGay-0000xD-TL for gllmg-musl@m.gmane.org; Fri, 14 Aug 2015 17:08:36 +0200 Original-Received: (qmail 20092 invoked by uid 550); 14 Aug 2015 15:08:35 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 20074 invoked from network); 14 Aug 2015 15:08:34 -0000 Mail-Followup-To: musl@lists.openwall.com, Jan V??el?k Content-Disposition: inline In-Reply-To: <20150814150038.GF27440@port70.net> User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:8300 Archived-At: * Szabolcs Nagy [2015-08-14 17:00:39 +0200]: > * Rich Felker [2015-08-14 10:15:40 -0400]: > > On Fri, Aug 14, 2015 at 11:34:32AM +0200, Szabolcs Nagy wrote: > > > * Jan V??el?k [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.