Open
Description
- 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: Latest python3.13.3-bookworm Dockerfile
- Pendulum version: 3.1.0
Issue
First, this was not an issue running Pendulum 3.0.0 in Python 3.12. We updated to Python 3.13.3 and installed Pendulum 3.1.0 and noticed that precise_diff
, when using the Rust version, returns nonsensical results whereas if we import the Python version directly, it works. Here's a simple example where we copied the _helpers.py
file into a local precise_diff.py
file.
Python 3.13.3 (main, May 22 2025, 18:04:33) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pendulum
>>> from util.precise_diff import precise_diff # This is just a copy paste of _helpers.py from the Pendulum repo
>>> d1 = pendulum.datetime(2025,6,2,10)
>>> d2 = pendulum.datetime(2025,6,2,13) # Create a second datetime 3 hours later.
>>> pendulum.helpers.precise_diff(d2,d1)
PreciseDiff(years=0, months=0, days=0, hours=-13, minutes=0, seconds=0, microseconds=0, total_days=0)
>>> precise_diff(d2,d1)
0 years 0 months 0 days -3 hours 0 minutes 0 seconds 0 microseconds
As you can see, when using our local copy (that uses Python), it returns -3 hours which is what you expect. It is returning -13 hours using the built in one that appears to use the Rust code as you can confirm by the fact that the representation of PreciseDiff
in each case is different.
Metadata
Metadata
Assignees
Labels
No labels