Date: Tue, 25 Jul 2000 01:58:37 +0200 From: Bernd Luevelsmeyer <bernd.luevelsmeyer@heitec.net> To: freebsd-bugs@FreeBSD.org Cc: Phil Pennock <pdp@nl.demon.net> Subject: Re: misc/20159: strftime() can't produce ISO8601 format timezone representation Message-ID: <397CD82D.F67AA13E@heitec.net> References: <E13GqO3-000HRe-00@samhain.noc.nl.demon.net> <200007242210.PAA15988@freefall.freebsd.org> <20000725002527.A67116@samhain.noc.nl.demon.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Phil Pennock wrote: > > On 2000-07-24 at 15:10 -0700, gnats-admin@FreeBSD.org wrote: > > It has the internal identification `misc/20159'. > > > >Synopsis: strftime() can't produce ISO8601 format timezone representation > > I have been informed that GNU strftime() implements this same behaviour, > using %z in the same way. My only available reference is an old Debian > box which does not document this. I have not examined the code. This > is a clean-room implementation. According to the new C Standard (C99), %z is supposed to be replaced by "the offset from UTC in the ISO 8601 format ‘‘0430’’ (meaning 4 hours 30 minutes behind UTC, west of Greenwich), or by no characters if no time zone is determinable." It's not determinable if tm_isdst is negative. %Z ought to be replaced by "the locale’s time zone name or abbreviation, or by no characters if no time zone is determinable.". The names are locale-dependent, and in the C locale they are implementation-defined. In the old Standard (C89) %z is undefined, and %Z is defined to be replaced by "the time zone name, or by no characters if no time zone is determinable." I think if strftime() were to be modified then the implementation ought to follow the C99 Standard. > Thinking about -0000 ("not telling you my timezone") - I seem to recall > that there was a struct tm entry which could be used for this. An old > fuzzy memory suggests tm_isdst, but this is not documented on FreeBSD > strftime(3). strftime.c has %Z giving '?' if tm_isdst is not either 0 If I understand correctly, tm_isdst is in fact the flag to indicate this, but the result should really be "no characters" if the TZ is unknown. FreeBSD's not documenting may be due to the fact that the system is always running in a known TZ, defaulting to UTC. > or 1 - my memory suggests -1. This would have been either Solaris or According to the Standard, positive means 'daylight saving time', 0 means 'normal time' and negative means 'unknown'. > GNU, from documentation read some time ago. If an definitive answer for > this can be given, the code mod is trivial. > > A feature request (already!) is to support +nn:nn which allegedly the > GNU version can't handle. Could someone with appropriate authority > please say if it is acceptable to use %Ez? I suspect not. :^/ Neither %z nor %Z have an E or O modifier defined by the Standard; that would be undefined behaviour then, which FreeBSD's implementation would take the liberty to define. IMHO that's ok (the compiler can do anything it likes if the source contains undefined behaviour, including something sensible), but all the sources using the feature would be unportable. (There's also a new 'struct tmx' in C99, which contains a member 'tm_zone' providing the timezone directly in minutes. It's used by mkxtime(), strfxtime() and related functions. You still don't get a %Ez from this, though.) The Standard is available at http://anubis.dkuug.dk/JTC1/SC22/open/n2794/n2794.pdf in a draft version. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?397CD82D.F67AA13E>