ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
563 stars 47 forks source link

fix pythonCollectionFromPropertyList fails on converting dates prior to year 1970 #596

Open ZigZagT opened 8 months ago

ZigZagT commented 8 months ago

Fixes a issue where pythonCollectionFromPropertyList crashes on dates prior to year 1970.

Both NSDate and python's datetime classes are capable of handling dates prior to 1970/01/01. However, the datetime.fromtimestamp API does not. It would throw the following exception:

  File "/opt/homebrew/lib/python3.11/site-packages/PyObjCTools/Conversion.py", line 220, in pythonCollectionFromPropertyList
    return datetime.datetime.fromtimestamp(aCollection.timeIntervalSince1970())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: year 0 is out of range
ZigZagT commented 8 months ago

pre-commit is not working

black....................................................................

(timeout after 180 seconds)