Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue2782] datetime/date strftime() method and time.strftime() inconsistency

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

May 7, 2008, 7:45 AM

Post #1 of 3 (326 views)
Permalink
[issue2782] datetime/date strftime() method and time.strftime() inconsistency

New submission from Andrii V. Mishkovskyi <mishok13 [at] gmail>:

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

----------
components: Library (Lib)
messages: 66360
nosy: mishok13
severity: normal
status: open
title: datetime/date strftime() method and time.strftime() inconsistency
type: behavior
versions: Python 2.5, Python 2.6

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2782>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 9, 2008, 11:11 AM

Post #2 of 3 (305 views)
Permalink
[issue2782] datetime/date strftime() method and time.strftime() inconsistency [In reply to]

Changes by broadus jones <broadus.jones [at] gmail>:


----------
nosy: +sbj3

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2782>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 9, 2008, 10:03 PM

Post #3 of 3 (296 views)
Permalink
[issue2782] datetime/date strftime() method and time.strftime() inconsistency [In reply to]

Changes by Alexandr Zamaraev <shura_zam [at] users>:


----------
nosy: +shura_zam

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue2782>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.