diff --git a/pendulum/datetime.py b/pendulum/datetime.py index abca24a8..6c423037 100644 --- a/pendulum/datetime.py +++ b/pendulum/datetime.py @@ -1256,11 +1256,11 @@ def _nth_of_month(self, nth, day_of_week): return self.first_of("month", day_of_week) dt = self.first_of("month") - check = dt.format("%Y-%m") + check = dt.format("%Y-%M") for i in range(nth - (1 if dt.day_of_week == day_of_week else 0)): dt = dt.next(day_of_week) - if dt.format("%Y-%m") == check: + if dt.format("%Y-%M") == check: return self.set(day=dt.day).start_of("day") return False diff --git a/tests/date/test_day_of_week_modifiers.py b/tests/date/test_day_of_week_modifiers.py index 0b12a98f..e65a13c0 100644 --- a/tests/date/test_day_of_week_modifiers.py +++ b/tests/date/test_day_of_week_modifiers.py @@ -111,7 +111,7 @@ def test_last_friday_of_month(): def test_nth_of_month_outside_scope(): - d = pendulum.date(1975, 12, 5) + d = pendulum.date(1975, 6, 5) with pytest.raises(PendulumException): d.nth_of("month", 6, pendulum.MONDAY) diff --git a/tests/datetime/test_day_of_week_modifiers.py b/tests/datetime/test_day_of_week_modifiers.py index a1091022..7b476418 100644 --- a/tests/datetime/test_day_of_week_modifiers.py +++ b/tests/datetime/test_day_of_week_modifiers.py @@ -127,7 +127,7 @@ def test_last_friday_of_month(): def test_nth_of_month_outside_scope(): - d = pendulum.datetime(1975, 12, 5) + d = pendulum.datetime(1975, 6, 5) with pytest.raises(PendulumException): d.nth_of("month", 6, pendulum.MONDAY)