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

Mailing List Archive: Python: Bugs

[issue14781] strptime fails for year 0

 

 

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


report at bugs

May 11, 2012, 3:54 AM

Post #1 of 3 (52 views)
Permalink
[issue14781] strptime fails for year 0

New submission from Matthias Meyer <meyer.matze [at] googlemail>:

Hi folks,

What I did:
import time
time.strptime('0000-10-03T15:35:05Z','%Y-%m-%dT%H:%M:%SZ')

What I expected:
time.struct_time(tm_year=0, tm_mon=10, tm_mday=3, tm_hour=15, tm_min=35, tm_sec=5, tm_wday=2, tm_yday=276, tm_isdst=-1)

What I got:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/_strptime.py", line 454, in _strptime_time
return _strptime(data_string, format)[0]
File "/usr/lib/python2.7/_strptime.py", line 440, in _strptime
datetime_date(year, 1, 1).toordinal() + 1
ValueError: year is out of range


Environment:
Ubuntu 12.04 x64
python --version: 2.7.3


If you need more information, please let me know...

----------
components: Library (Lib)
messages: 160404
nosy: Matthias.Meyer
priority: normal
severity: normal
status: open
title: strptime fails for year 0
type: crash
versions: Python 2.7

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14781>
_______________________________________
_______________________________________________
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 11, 2012, 4:20 AM

Post #2 of 3 (50 views)
Permalink
[issue14781] strptime fails for year 0 [In reply to]

Hynek Schlawack <hs [at] ox> added the comment:

Hello Matthias,

%Y for strptime is defined as:

"Year with century as a decimal number [0001,9999] (strptime), […]"

so it works as specified. And actually that's correct as there was no year zero (http://en.wikipedia.org/wiki/0_(year)). :)

----------
nosy: +hynek
resolution: -> invalid

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14781>
_______________________________________
_______________________________________________
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 11, 2012, 4:29 AM

Post #3 of 3 (53 views)
Permalink
[issue14781] strptime fails for year 0 [In reply to]

Matthias Meyer <meyer.matze [at] googlemail> added the comment:

but ISO 8601 specifies year 0 to be identical with 1 BC. Shouldn't it default to that, then?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14781>
_______________________________________
_______________________________________________
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.