kennethreitz / maya

Datetimes for Humans™
MIT License
3.41k stars 199 forks source link

Fallback on error in datetime() before year 1970 #193

Closed Lenqth closed 3 months ago

Lenqth commented 3 years ago

Describe the bug

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda\python3\envs\***\lib\site-packages\maya\core.py", line 250, in datetime
    dt = Datetime.utcfromtimestamp(self._epoch)
OSError: [Errno 22] Invalid argument

when MayaDT.datatime() (calls utcfromtimestamp) with negative epoch MayaDT object.

Environment and Version

To Reproduce ( note that occured on Windows environment , but maybe not on Linux environment )

import maya
maya.when("1949-01-01").datetime()

Expected behavior

>>> import maya
>>> maya.when("1949-01-01").datetime()
datetime.datetime(1949, 1, 1, 0, 0, tzinfo=<UTC>)
kennethreitz commented 3 months ago

thanks!