Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pendulum/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def is_same_day(self, dt: date) -> bool:
"""
Checks if the passed in date is the same day as the instance current day.
"""
return self == dt
return (self.year, self.month, self.day) == (dt.year, dt.month, dt.day)

def is_anniversary(self, dt: date | None = None) -> bool:
"""
Expand Down
11 changes: 11 additions & 0 deletions tests/date/test_comparison.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from datetime import date
from datetime import datetime

import pendulum

Expand Down Expand Up @@ -240,6 +241,16 @@ def test_is_same_day():
assert not dt1.is_same_day(dt5)


def test_is_same_day_with_datetime():
d = pendulum.Date(2015, 5, 28)

assert d.is_same_day(datetime(2015, 5, 28, 10))
assert d.is_same_day(pendulum.datetime(2015, 5, 28, 10))
assert d.is_same_day(pendulum.datetime(2015, 5, 28, 0, tz="Europe/Paris"))
assert not d.is_same_day(datetime(2015, 5, 29, 10))
assert not d.is_same_day(pendulum.datetime(2015, 5, 29, 10))


def test_comparison_to_unsupported():
dt1 = pendulum.Date.today()

Expand Down