For some reason when constructing datetimes using fromtimestamp, I get a \"OSError [Errno22] Invalid Argument\" when I use negative times less than -43200 (-12hrs). I am on
@wim's answer is correct, but anyone else arriving here might be interested in testing it (adjust range if you wish):
import datetime
import platform
print(
"Running on Python ver.{} on {} {}\n" \
.format(
platform.python_version(),
platform.system(),
platform.release()
)
)
for timestamp in range(1, 100000000):
try:
dt = datetime.datetime.fromtimestamp(timestamp)
except:
pass
else:
break
print(
"Smallest accepted Unix timestamp by {}: '{}' ({})" \
.format(platform.system(), timestamp, dt)
)
What I got was:
A:\src\X.utilities>test.py
Running on Python ver.3.6.1 on Windows 7
Smallest accepted Unix timestamp by Windows: '86400' (1970-01-02 02:00:00)