Python pendulum module returning wrong week number
Question:
The way iam trying to get the week number
import pendulum
from datetime import date
dt = pendulum.parse(str(date.today()))
week = dt.week_of_month
print(dt)
print(week)
Result
2023-01-19T00:00:00+00:00
-48
The week number is -48 here, please help me to get the correct week number of the month
Answers:
There is an issue going with pendulum module. It is returning negative numbers for week.
Please find the attached link for reference:
As @God is One mentioned in the above answer, there’s an issue with the current version and the rest of the versions in the 2.1.x series. But then when I tried to downgrade it to 2.0.5
, this worked fine and it returned the expected value.
Maybe that’s the only option as of now if you’re to go with this library.
The way iam trying to get the week number
import pendulum
from datetime import date
dt = pendulum.parse(str(date.today()))
week = dt.week_of_month
print(dt)
print(week)
Result
2023-01-19T00:00:00+00:00
-48
The week number is -48 here, please help me to get the correct week number of the month
There is an issue going with pendulum module. It is returning negative numbers for week.
Please find the attached link for reference:
As @God is One mentioned in the above answer, there’s an issue with the current version and the rest of the versions in the 2.1.x series. But then when I tried to downgrade it to 2.0.5
, this worked fine and it returned the expected value.
Maybe that’s the only option as of now if you’re to go with this library.