From 726b4a93703d7b4a040a527be60e4f4c37975f48 Mon Sep 17 00:00:00 2001 From: s3lph Date: Sat, 3 Nov 2018 21:22:25 +0100 Subject: [PATCH] Remplaced a calendar function not available in Python 3.6 --- matemat/util/monthdelta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matemat/util/monthdelta.py b/matemat/util/monthdelta.py index 49c1fa0..78cbd28 100644 --- a/matemat/util/monthdelta.py +++ b/matemat/util/monthdelta.py @@ -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)