- OS version and name: MacOS 14.5
- Pendulum version: 3.0
Issue
While tinkering with Duration, I found several bugs and edge cases that might be good to patch:
Parsing partially ignores long numbers
>>> parse ('PT999900000000000000000000000000000002S')
Duration(seconds=2) # earlier digits get forgotten
Incorrectly duplicated components are parsed anyway, with inconsistent results
>>> parse("P12M4M")
Duration(months=4) # should be an error, but takes the last one
>>> parse("PT12M3M1M")
Duration(minutes=16) # should also be an error, but sums them
Values overflow
>>> parse("PT4294967297M")
Duration(minutes=1)
'empty' duration shouldn't be allowed
>>> parse('PT')
Duration() # should be an error, this isn't allowed in ISO8601
Strange month arithmetic
>>> parse("P1M") + Duration()
Duration(weeks=4, days=2)
>>> Duration(months=1) * 1.0
Duration()
>>> Duration(months=1) * 1
Duration(months=1)
Probably related to #799
Issue
While tinkering with
Duration, I found several bugs and edge cases that might be good to patch:Parsing partially ignores long numbers
Incorrectly duplicated components are parsed anyway, with inconsistent results
Values overflow
'empty' duration shouldn't be allowed
Strange month arithmetic
Probably related to #799