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

something worry in dt.week_of_month #455

Closed
zhenghao0379 opened this issue Mar 30, 2020 · 3 comments · Fixed by #774
Closed

something worry in dt.week_of_month #455

zhenghao0379 opened this issue Mar 30, 2020 · 3 comments · Fixed by #774

Comments

@zhenghao0379
Copy link

dt = pendulum.parse('2000-01-03')
dt.week_of_month

return -50

and '2029-12-31' return -46

@SuperStormer
Copy link

SuperStormer commented May 6, 2020

The reason for this issue is that datetime.datetime.isocalendar, as used in week_of_year here, returns the last week of 1999 for 2000-01-01(used by week_of_month for its calculations) and the 1st week of 2030 for the second date. Implementing something along the lines of this should fix it. This issue appears to have been introduced by #446.

@harrisonjohn
Copy link

harrisonjohn commented Jan 4, 2021

I just wanted to add that this issue exists with basically the first month of the year that the 1st of Jan is on a Friday or Sat. Just had a personal project go boom on the new year 😄.

Potential solution here for future viewers of this issue: https://stackoverflow.com/questions/61641626/what-week-of-the-month-is-it

Another solution is 2.0.5 has a working week_of_month from what I can tell, not sure what fixes you are losing with this version though.

I would look to PR a fix, but it does not look like a PR has been accepted in months.

@jbnjohnathan
Copy link

jbnjohnathan commented Jan 21, 2021

I also found this issue now in version 2.1.2

>>> pendulum.now().week_of_month
-49

I am surprised that it was discovered last year but not fixed in latest package. I guess I need to downgrade to 2.0.5

Edit: Confirmed to work in 2.0.5

>>> pendulum.now().week_of_month
3

sdispater added a commit that referenced this issue Dec 14, 2023
sdispater added a commit that referenced this issue Dec 15, 2023
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 a pull request may close this issue.

4 participants