August 2018
Intermediate to advanced
366 pages
10h 14m
English
As pointed out in the recipe introduction, there is a limit to how big a number can be for a computer. For that reason, it's important to note that while datetime.datetime can represent practically any date, a timestamp can't.
For example, trying to represent a datetime from 1300 will succeed but it will fail to convert it to a timestamp:
>>> datetime.datetime(1300, 1, 1) datetime.datetime(1300, 1, 1, 0, 0) >>> datetime.datetime(1300, 1, 1).timestamp() Traceback (most recent call last): File "<stdin>", line 1, in <module> OverflowError: timestamp out of range
A timestamp is only able to represent dates starting from January 1st, 1970.
The same is true also in the reverse direction for faraway dates, while 253402214400 represents ...