tags:

views:

75

answers:

1

on google appengine (http://shell.appspot.com/):

>>> time.gmtime(1000*365*24*60*60)
(2969, 5, 3, 0, 0, 0, 2, 123, 0)

on macosx:

>>> time.gmtime(1000*365*24*60*60)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: timestamp out of range for platform time_t

is there a platform agnostic implementation of time.gmtime?

+1  A: 

The time module is defined to be platform-specific.

The functions in this module do not handle dates and times before the epoch or far in the future. The cut-off point in the future is determined by the C library; for Unix, it is typically in 2038.

You can use the datetime type without timezone info ("naive datetimes"), understood by convention in your program to be GMT, or follow the (complicated) tzinfo instructions in the docs.

>>> import datetime
>>> datetime.datetime(2969, 5, 3).year
2969
>>> datetime.MINYEAR, datetime.MAXYEAR
(1, 9999)
Roger Pate