isodatetime icon indicating copy to clipboard operation
isodatetime copied to clipboard

Adding duration in months to a TimePoint can give incorrect result for 31st of month

Open MetRonnie opened this issue 1 year ago • 0 comments

Correct:

>>> TimePoint(year=2023, month_of_year=7, day_of_month=31) + Duration(months=1)
2023-08-31

Also correct (last day of month):

>>> TimePoint(year=2023, month_of_year=8, day_of_month=31) + Duration(months=1)
2023-09-30

Incorrect:

>>> TimePoint(year=2023, month_of_year=8, day_of_month=31) + Duration(months=2)
2023-10-30 

(should be 2023-10-31)

This will probably need similar re-work as done in #234

See

https://github.com/metomi/isodatetime/blob/41bc38ff234c903e6ab6ed60e95dcc90b088d9b6/metomi/isodatetime/data.py#L1684-L1686

https://github.com/metomi/isodatetime/blob/41bc38ff234c903e6ab6ed60e95dcc90b088d9b6/metomi/isodatetime/data.py#L1835-L1837

MetRonnie avatar May 21 '24 11:05 MetRonnie