Remplaced a calendar function not available in Python 3.6
This commit is contained in:
parent
fe1f52a954
commit
726b4a9370
1 changed files with 1 additions and 1 deletions
|
@ -20,7 +20,7 @@ def add_months(d: datetime, months: int) -> datetime:
|
|||
days: int = 0
|
||||
# Iterate the months between the passed date and the target month
|
||||
for i in range(months):
|
||||
days += calendar.monthlen(*nextmonth)
|
||||
days += calendar.monthrange(*nextmonth)[1]
|
||||
nextmonth = calendar.nextmonth(*nextmonth)
|
||||
# Set the day of month temporarily to 1, then add the day offset to reach the 1st of the target month
|
||||
newdate: datetime = d.replace(day=1) + timedelta(days=days)
|
||||
|
|
Loading…
Reference in a new issue