[ python-Bugs-1633628 ] time.strftime() accepts format which time.strptime doesnt

SourceForge.net noreply at sourceforge.net
Mon Jan 15 20:15:47 CET 2007


Bugs item #1633628, was opened at 2007-01-11 15:44
Message generated for change (Comment added) made by bcannon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1633628&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
>Status: Closed
>Resolution: Invalid
Priority: 5
Private: No
Submitted By: Matthias Klose (doko)
Assigned to: Nobody/Anonymous (nobody)
Summary: time.strftime() accepts format which time.strptime doesnt

Initial Comment:
[forwarded from http://bugs.debian.org/354636]

time.strftime() accepts '%F %T' as format but time.strptime() doesn't, if
the rule is "all what strftime accepts strptime must also" then that is
bad. Check this:

darwin:~# python2.4
Python 2.4.2 (#2, Nov 20 2005, 17:04:48) 
[GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> format = '%F %T'
>>> t = time.strftime(format)
>>> t
'2006-02-27 18:09:37'
>>> time.strptime(t,format)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/_strptime.py", line 287, in strptime
    format_regex = time_re.compile(format)
  File "/usr/lib/python2.4/_strptime.py", line 264, in compile
    return re_compile(self.pattern(format), IGNORECASE)
  File "/usr/lib/python2.4/_strptime.py", line 256, in pattern
    processed_format = "%s%s%s" % (processed_format,
KeyError: 'F'
>>> 


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

>Comment By: Brett Cannon (bcannon)
Date: 2007-01-15 11:15

Message:
Logged In: YES 
user_id=357491
Originator: NO

It is not a goal of strptime to support directive that are not explicitly
documented as supported.  time.strftime uses the platform's implementation
which can implement more directives than documented.  But strptime is meant
to be fully platform-independent for those directive documented only. 
Trying to support all directives for all platforms is just a practice in
futility considering how many they are and how they might be implemented
differently.

As both directives mentioned here are not documented as supported I am
closing as invalid.

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

Comment By: Mark Roberts (mark-roberts)
Date: 2007-01-14 16:40

Message:
Logged In: YES 
user_id=1591633
Originator: NO

For record:
%F = '%Y-%m-%d'
%T = '%H:%M:%S'.

Patch 1635473:
http://sourceforge.net/tracker/index.php?func=detail&aid=1635473&group_id=5470&atid=305470

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

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


More information about the Python-bugs-list mailing list