Mail Archives: djgpp/2000/12/21/18:58:13
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:
> On Wed, 20 Dec 2000, Jason Green wrote:
> > There appears to be a bug in strftime() when using the %z format.
>
> The bug, whether it exists or not, does not necessarily have anything
> to do with what Felix reported: I replied to his message saying I
> cannot reproduce the problem. His test program wroked for me. I
Perhaps you could try my test program too, and tell if it does what
you expect it should?
> > Well, actually not so much a bug as a feature. ;-)
>
> Actually, %z is undocumented and should not be used at all in the
> DJGPP version of strftime.
Yes, I meant to say "an undocumented feature". Of course, this could
change if we can agree on what %z should actually do.
> > With existing strftime the test program outputs:
> >
> > Wed, 20 Dec 2000 20:35:42 +0000 GMT
> > Wed, 20 Dec 2000 20:35:42 +0000 GMT
> > Wed, 20 Dec 2000 08:01:42 -0000 TEST1
> > Thu, 21 Dec 2000 09:09:42 +45240 TEST2
> >
> > After patching the test program outputs:
> >
> > Wed, 20 Dec 2000 20:36:21 +0000 GMT
> > Wed, 20 Dec 2000 20:36:21 +0000 GMT
> > Wed, 20 Dec 2000 08:02:21 -1234 TEST1
> > Thu, 21 Dec 2000 09:10:21 +1234 TEST2
>
> Note that your changes modified the bahavior of %z: it is supposed to
> print the values in seconds, while your version prints it in hours and
> minutes instead. So this is more than just a bugfix for the negative
> offsets.
Correct. My previous message wasn't too clear - I'm claiming that for
%z to print seconds is a bug, and the patch is to fix that (as well as
negative offsets). So this is intentional.
The POSIX Programmer's Guide isn't too helpful on this matter. It
lists: "%z Time zone.", %Z isn't listed.
The Linux man page for strftime() is better:
%z The time-zone as hour offset from GMT. Required to
emit RFC822-conformant dates (using "%a, %d %b %Y
%H:%M:%S %z"). (GNU)
%Z The time zone or name or abbreviation.
RFC822 says in section 5.1:
zone = "UT" / "GMT" ; Universal Time
; North American : UT
/ "EST" / "EDT" ; Eastern: - 5/ - 4
/ "CST" / "CDT" ; Central: - 6/ - 5
/ "MST" / "MDT" ; Mountain: - 7/ - 6
/ "PST" / "PDT" ; Pacific: - 8/ - 7
/ 1ALPHA ; Military: Z = UT;
; A:-1; (J not used)
; M:-12; N:+1; Y:+12
/ ( ("+" / "-") 4DIGIT ) ; Local differential
; hours+min. (HHMM)
Here is output from my test program under Linux:
Thu, 21 Dec 2000 23:33:45 +0000 GMT
Thu, 21 Dec 2000 23:33:45 +0000 GMT
Thu, 21 Dec 2000 10:59:45 -1234 TEST1
Fri, 22 Dec 2000 12:07:45 +1234 TEST2
So I think my patch to strftime() makes it behave properly (and at
least gives the behaviour that Felix is looking for).
Of course, %z can be made to do whatever we want. So if you think it
should do something else please say so and I will try to code for
that.
Maybe you have a copy of the ANSI standard to check on this? (I do
not have a copy here).
- Raw text -