metomi/isodatetime

Inconsistency between truncated dates and truncated times

MetRonnie opened this issue · 0 comments

When adding a truncated TimePoint to a regular TimePoint, if the truncated one specifies a date, all units smaller than the ones provided are not taken into account, whereas if it specifies a time, the smaller units are implicitly zero.

>>> parser = TimePointParser(allow_truncated=True)
>>> regular = parser.parse("2010-08-08T15:40:13Z")
>>> truncated_date = parser.parse("--10")  # month = 10 (October)
>>> regular + truncated_date
<metomi.isodatetime.data.TimePoint: 2010-10-08T15:40:13Z>

Note how the day of month and time from the regular TimePoint are retained

>>> truncated_time = parser.parse("T19")
>>> regular + truncated_time
<metomi.isodatetime.data.TimePoint: 2010-08-08T19:00:00Z>

Note how the minutes and seconds have gone to zero, as if they were taken from the truncated TimePoint which is assumed to be equivalent to T19:00:00.

To me, it seems debatable which is the correct approach for addition of regular and truncated TimePoints, but at least the approach should be consistent.