-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix parsing of ISO8601 durations #37159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9292728
Fix parsing of ISO8601 strings with empty period
mgmarino d8e8ad9
Add 'W' as a valid ISO 8601 designator
mgmarino fbf93da
Parse all components of ISO 8601 durations, even if S is not included
mgmarino 949fa5e
Use chained comparison
mgmarino 0511e01
Add what's new entry
mgmarino 3786f8b
Remove limitation that seconds has two or fewer digits
mgmarino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we handle negatives of these? (IIRC that's on one of the issues)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't change the behavior of negativity, and the question is how to handle it. One of the only references I can find regarding the expected behavior is this comment, which also seems to indicate it's not very well defined in the ISO 8601 standard. How would you feel about pulling that out into a separate issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes pls create a separate issue. only thing for now is do we raise if a negative is passed in? (i think we should unless / until we decide on how to handle it), though isn't the result just negative of the Timedelta itself which is well defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will do.
No, nothing is raised when it is negative, and the behavior is, admittedly, quite odd, i.e.
"P-6DT0H50M3.010010012S"
parses asTimedelta( days=-6, minutes=50, seconds=3, milliseconds=10, microseconds=10, nanoseconds=12, )
, and the negative is only allowed right after the P descriptor. A negative in any other position will raise an error. As far as I can tell, there are two possibilities to go here:
"-P6DT1H" = Timedelta('-7 days +23:00:00')
and/or"P7DT-1H3M" = Timedelta('6 days 23:03:00')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue now here: #37172. I would prefer to change/update the negativity behavior in a separate PR if that's ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep that's great. well scoped PRs are good. one thing at a time. and thanks for working on this.