isodatetime icon indicating copy to clipboard operation
isodatetime copied to clipboard

Traceback when converting truncated week date, with year of decade, to calendar date

Open MetRonnie opened this issue 10 months ago • 0 comments

>>> a = TimePoint(year=1, week_of_year=2, truncated=True, truncated_property=year_of_decade)

>>> a
<metomi.isodatetime.data.TimePoint: -1-W02>

>>> a.to_calendar_date()
...
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

I think converting to a calendar date (i.e. month of year and day of month, instead of week of year and day of week) is not possible for a time point with truncated year, because it depends on the exact year. We should raise a ValueError or BadInputError with a more useful error message.

MetRonnie avatar Apr 30 '25 13:04 MetRonnie