Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix leap year & negative week number issue #766

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kwongtn
Copy link

@kwongtn kwongtn commented Nov 1, 2023

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.
    ^ There are no related documentation

This PR attempts to fix the following issues:

If this PR is merged, the following PRs should be closed too:

The following tests are mapped to their respective issues:

# https://github.com/sdispater/pendulum/issues/438
assert pendulum.Date(2020, 1, 7).week_of_month == 2
assert pendulum.Date(2020, 1, 14).week_of_month == 3

# https://github.com/sdispater/pendulum/issues/455
assert pendulum.Date(2000, 1, 1).week_of_month == 1
assert pendulum.Date(2000, 1, 3).week_of_month == 2
assert pendulum.Date(2029, 12, 31).week_of_month == 6

# https://github.com/sdispater/pendulum/issues/536
assert pendulum.Date(2019, 12, 29).week_of_month == 5
assert pendulum.Date(2019, 12, 31).week_of_month == 6
assert pendulum.Date(2019, 12, 30).week_of_month == 6
assert pendulum.Date(2021, 1, 2).week_of_month == 1
assert pendulum.Date(2021, 1, 9).week_of_month == 2
assert pendulum.Date(2021, 1, 16).week_of_month == 3
assert pendulum.Date(2021, 1, 23).week_of_month == 4
assert pendulum.Date(2021, 1, 30).week_of_month == 5

# https://github.com/sdispater/pendulum/issues/587
assert pendulum.Date(2021, 1, 15).week_of_month == 3
assert pendulum.Date(2023, 1, 2).week_of_month == 1

# https://github.com/sdispater/pendulum/issues/598
assert pendulum.Date(2022, 1, 1).week_of_month == 1
assert pendulum.Date(2022, 1, 3).week_of_month == 2
assert pendulum.Date(2022, 1, 10).week_of_month == 3
assert pendulum.Date(2021, 12, 29).week_of_month == 5
assert pendulum.Date(2021, 12, 30).week_of_month == 5
assert pendulum.Date(2021, 12, 31).week_of_month == 5

@kwongtn kwongtn marked this pull request as draft November 2, 2023 00:50
There should be no week_of_month == 0 situations
@kwongtn kwongtn marked this pull request as ready for review November 2, 2023 01:26
@@ -63,6 +63,37 @@ def test_week_of_month():
assert pendulum.date(2020, 1, 14).week_of_month == 3


def test_week_of_month_negative():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could parametrize this test using @pytest.mark.parametrize

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.

None yet

2 participants