Skip to content

Bugs in Duration edge cases #833

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
2 tasks done
ariebovenberg opened this issue Jun 10, 2024 · 0 comments
Open
2 tasks done

Bugs in Duration edge cases #833

ariebovenberg opened this issue Jun 10, 2024 · 0 comments

Comments

@ariebovenberg
Copy link

  • I am on the latest Pendulum version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • 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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant