[Python-bugs-list] [ python-Bugs-437041 ] strfime %Z isn't an RFC 822 timezone

noreply@sourceforge.net noreply@sourceforge.net
Fri, 29 Jun 2001 08:43:30 -0700


Bugs item #437041, was opened at 2001-06-28 04:19
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=437041&group_id=5470

Category: Documentation
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Carey Evans (carey)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: strfime %Z isn't an RFC 822 timezone

Initial Comment:
The section in the library reference manual for the
time module says, under strftime:

"""Here is an example, a format for dates compatible
with that specified in the RFC 822 Internet email
standard."""

And goes on to use %Z with localtime().  However, %Z
for me returns "NZST" and may return a full description
under other OSes.  RFC 822 only lists a few
abbreviations as valid, and NZST isn't one of them.

In addition, RFC 822 has now been obsoleted by RFC
2822, which deprecates the use of abbreviations for
time zones.

To generate an RFC 2822 date string, you can either use
gmtime():

    strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())

or do a bit of math:

    t = localtime()
    dst = t[8]
    offs = (timezone, timezone, altzone)[1 + dst]
    zstr = "%+.2d%.2d" % (offs / -3600, abs(offs / 60)
% 60)
    print strftime("%a, %d %b %Y %H:%M:%S ", t) + zstr

Also note that these only work if the LC_TIME locale
category hasn't been set to a non-English locale.

Maybe "%Y-%m-%d %H:%M:%S" would be a better example,
for an ISO8601 formatted time?


On a positive note, RFC 2822 defines a year as four
digits, so the footnote could be updated.


----------------------------------------------------------------------

>Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-06-29 08:43

Message:
Logged In: YES 
user_id=3066

Fixed in Doc/lib/libtime.tex revisions 1.39 and 1.16.4.2.
Thanks!

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=437041&group_id=5470