time module error.
Chris Barker
chrishbarker at home.net
Thu Sep 13 12:27:17 EDT 2001
Des Small wrote:
> >>> t = time.strptime( '2',"%H")
> >>> t
> (1900, 1, 0, 2, 0, 0, 6, 1, 0)
> >>> time.mktime(t)
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> OverflowError: mktime argument out of range
> Now, I can easily enough convert hours to seconds in my own code, but
> I don't understand why the above fails.
mktime() can't handle the year 1900 or 1901, but 1902 and so on works.
Oddly enough, if you try to put in 1800, you get:
>>> time.mktime((1800, 1, 1, 0, 0, 0, 3, 1, 0))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: year out of range (00-99, 1900-*)
Which implies that it should handle 1900.
The time() module is just a wrapper around the C time library, whixh is
really pretty limited. so as not to re-invent the wheel, and to get a
lot more power and functionality, I highly recomend mxDateTime:
http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#mxDateTime
-Chris
--
Christopher Barker,
Ph.D.
ChrisHBarker at home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------
More information about the Python-list
mailing list