#956·pendulum

`from_timestamp` fails with timestamps earlier than 12h before unix epoch

Author: dr-emeCreated Apr 3, 2026Updated Apr 22, 2026
  • I am on the latest Pendulum version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • OS version and name: Win11

  • Pendulum version: 3.2.0

Issue

pendulum.from_timestamp() throws OSError when attempting to convert a timestamps earlier than 12h before the unix epoch.

python
>>> pendulum.from_timestamp(-43200)
DateTime(1969, 12, 31, 12, 0, 0, tzinfo=Timezone('UTC'))
>>> pendulum.from_timestamp(-43201)
Traceback (most recent call last):
  File "<python-input-5>", line 1, in <module>
    from_timestamp(-43201)
    ~~~~~~~~~~~~~~^^^^^^^^
  File "C:\sst\reportsgenservice\.venv\Lib\site-packages\pendulum\__init__.py", line 290, in from_timestamp
    dt = _datetime.datetime.fromtimestamp(timestamp, tz=UTC)
OSError: [Errno 22] Invalid argument

However, pendulum supports these dates without issues, for instance when parsing 0 dates from a database:

python
>>> pendulum.parse('1900-01-01')
DateTime(1900, 1, 1, 0, 0, 0, tzinfo=Timezone('UTC'))

Current workaround is to substract negative timestamps to an unix epoch datetime instance:

python
>>> pendulum.from_timestamp(0).add(seconds=-43201)
DateTime(1969, 12, 31, 11, 59, 59, tzinfo=Timezone('UTC'))

Source: python-pendulum/pendulum