isoduration icon indicating copy to clipboard operation
isoduration copied to clipboard

0.5 values in date durations are considered valid but interpreted as 1

Open dantman opened this issue 8 months ago • 0 comments

When 0.5 is used in a value, it ends up as 0.5 in the DateDuration but appears to actually increment a datetime by 1. This behaviour also seems to apply to YMD and HMS but W seems to work in an incomplete way.

from datetime import datetime
from isoduration import parse_duration
datetime(2023, 1, 1) + parse_duration('P0.5M')
# datetime.datetime(2023, 2, 1, 0, 0)
parse_duration('P0.5M')
# Duration(DateDuration(years=Decimal('0'), months=Decimal('0.5'), days=Decimal('0'), weeks=Decimal('0')), TimeDuration(hours=Decimal('0'), minutes=Decimal('0'), seconds=Decimal('0')))

dantman avatar Nov 03 '23 01:11 dantman