[Python-Dev] datetime module enhancements
lists at cheimes.de
Fri Mar 9 18:55:40 CET 2007
BJörn Lindqvist schrieb:
> I think it should be a ValueError, given that the programmer is very
> likely to further use the returned timestamp to for example insert
> stuff in a database. Unix timestamps are not unambiguously defined for
> any years other than 1970 to 2038 imho.
IIRC the unix timestamp was originally definied as *signed* int with 32bit.
Unix and POSIX-compliant systems implement the time_t type as a signed
integer (typically 32 or 64 bits wide) which represents the number of
seconds since the start of the Unix epoch: midnight UTC of January 1,
1970 (not counting leap seconds). Some systems support negative time
values, while others do not.
But you made a good point! What do you think about
datetime.totimestamp(asLong=False)? The method would raise a ValueError
or OverflowError if the value is > sys.maxint or < -(sys.maxint-1).
More information about the Python-Dev