This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mishok13
Recipients mishok13
Date 2008-05-07.14:45:41
SpamBayes Score 2.64486e-05
Marked as misclassified No
Message-id <1210171543.31.0.364893974178.issue2782@psf.upfronthosting.co.za>
In-reply-to
Content
datetime and date strftime() method does additional check on input
format, thus being completely different from time's module
time.strftime() method behavior.
There are two ways to fix this:
1. Add an explicit note about this behavior (e.g., "only 'str' objects
are allowed for format strings") in docs (section 5.1.7).
2. Allow 'unicode' objects for format strings (backport time.strftime()
from 3.0?).

Here is a traceback for a more complete overview:

Python 2.6a2+ (trunk:62762, May  6 2008, 14:37:27)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime, date
>>> import time
>>> uformat = u'%Y-%m-%D %H-%M-%S'
>>> format = '%Y-%m-%D %H-%M-%S'
>>> datetime.today().strftime(uformat)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: strftime() argument 1 must be str, not unicode
>>> datetime.today().strftime(format)
'2008-05-05/07/08 17-19-03'
>>> time.strftime(uformat)
'2008-05-05/07/08 17-19-10'
>>> time.strftime(format)
'2008-05-05/07/08 17-19-16'
>>> date.today()
datetime.date(2008, 5, 7)
>>> date.today().strftime(format)
'2008-05-05/07/08 00-00-00'
>>> date.today().strftime(uformat)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: strftime() argument 1 must be str, not unicode
History
Date User Action Args
2008-05-07 14:45:43mishok13setspambayes_score: 2.64486e-05 -> 2.64486e-05
recipients: + mishok13
2008-05-07 14:45:43mishok13setspambayes_score: 2.64486e-05 -> 2.64486e-05
messageid: <1210171543.31.0.364893974178.issue2782@psf.upfronthosting.co.za>
2008-05-07 14:45:42mishok13linkissue2782 messages
2008-05-07 14:45:41mishok13create