pendulum
pendulum copied to clipboard
something worry in dt.week_of_month
dt = pendulum.parse('2000-01-03')
dt.week_of_month
return -50
and '2029-12-31' return -46
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.
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.
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