time.strftime in 2.4.1 claims data out of range when not
Brian van den Broek
bvande at po-box.mcgill.ca
Fri Apr 22 03:25:32 EDT 2005
Sheila King said unto the world upon 2005-04-22 02:45:
> I have a web app that has been running just fine for several months under
> Python 2.2.2.
>
> We are preparing to upgrade the server to run Python 2.4.1.
>
> However, part of my web app is throwing an error on this code (that has
> previously worked without exception):
>
>
>>>>time.strftime("%Y-%m-%d", (Y, M, D, 0,0,0,0,0,0))
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> ValueError: day of year out of range
>
>>>>Y
>
> 2005
>
>>>>M
>
> 5
>
>>>>D
>
> 15L
>
>
> I don't see what parts of the date that I have submitted to strftime are out
> of range?
>
> Also, the phrasing of the error message is a bit odd?
> "day of year out of range"
>
> I'm not sure what the
> day of a year
>
> would be???
>
> Sheila King
> http://www.thinkspot.net/sheila/
>
>
The day of the year is the ordinal number of the day, counting from
Jan. 1st. So, Feb. 1st is the 32nd day, Dec 31 the 365/6 (depending on
leap year).
The docs for the time module indicate that the 8th (counting from 1)
position of a struct_time is the day of the year, and that it can
range from 1-366. So, naturally, the 0 value in your 8th position is
the problem.
That does leave the mystery of why your code worked on 2.2.2; I've no
idea. The docs do seem to indicate that there were a number of changes
at 2.2, though.
Best,
Brian vdB
More information about the Python-list
mailing list