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)