Skip to content

fix: accept naive stdlib datetime in DateTime.diff()#960

Closed
JKDasondee wants to merge 3 commits intopython-pendulum:masterfrom
JKDasondee:fix/880-diff-naive-stdlib-datetime
Closed

fix: accept naive stdlib datetime in DateTime.diff()#960
JKDasondee wants to merge 3 commits intopython-pendulum:masterfrom
JKDasondee:fix/880-diff-naive-stdlib-datetime

Conversation

@JKDasondee
Copy link
Copy Markdown

Fixes #880

DateTime.diff() raises TypeError when called with a naive stdlib datetime object on a naive DateTime. The fix wraps the stdlib datetime with pendulum.instance(dt, tz=None) to preserve naivety before passing to Interval.

DateTime.diff() raises TypeError when called with a naive stdlib datetime
on a naive DateTime. Wraps the input with pendulum.instance(dt, tz=None)
to preserve naivety before passing to Interval.

Fixes python-pendulum#880
@Secrus
Copy link
Copy Markdown
Collaborator

Secrus commented Apr 10, 2026

This is some weird mixture of commits. Please, clean up your work and provide tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

naive DateTime.diff fails when the input is a naive datetime object, as pendulum.instance converts it to a pendulum.DateTime with UTC tz

2 participants