Feature or enhancement
Proposal:
Currently to get the last day of the month, the most straightforward method is:
from calendar import monthrange
from datetime import date
mydate = date.today()
mydate.replace(day=monthrange(mydate.year, mydate.month)[1]) # date(2025, 10, 31)
I'd like to propose adding an end_of_month() method to the date class.
- As a class method it would return a last day of month for
year and month arguments.
- As an instance method it would return a last day of a month for a
date instance.
from datetime import date
date.end_of_month(2025, 11) # 2025-11-30
date.today().end_of_month() # 2025-10-31
It can be achieved with a “hybrid method” for Python implementation.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/idea-date-end-of-month/
Feature or enhancement
Proposal:
Currently to get the last day of the month, the most straightforward method is:
I'd like to propose adding an
end_of_month()method to thedateclass.yearandmontharguments.dateinstance.It can be achieved with a “hybrid method” for Python implementation.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/idea-date-end-of-month/