Skip to content
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

Fix parse panic #686

Merged
merged 2 commits into from Jun 9, 2022
Merged

Fix parse panic #686

merged 2 commits into from Jun 9, 2022

Conversation

botahamec
Copy link
Contributor

This is to resolve #645. The test was previously panicking when subtracting the FixedOffset from the NaiveDateTime. There may be other places that use that subtraction that we want to look at in the future.


// this is used to prevent an overflow when calling FixedOffset::from_local_datetime
datetime
.checked_sub_signed(OldDuration::seconds(i64::from(offset.local_minus_utc())))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, now that I'm looking at this in context I'm having second thoughts. What would it take to move this check into TimeZone::from_local_datetime()? Can you check what happens to that method in #677?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem I see is that TimeZone::from_local_datetime() returns a LocalResult, and I think it would be counter-intuitive if it returned LocalResult::None for that.

@djc
Copy link
Contributor

djc commented May 5, 2022

Thank you for working on this!

@botahamec
Copy link
Contributor Author

I had trouble fixing the merge conflict somehow, but it should be good now

@botahamec botahamec reopened this May 26, 2022
@djc djc merged commit 150f6d1 into chronotope:main Jun 9, 2022
@djc
Copy link
Contributor

djc commented Jun 9, 2022

Thanks!

@botahamec botahamec deleted the fix-parse-panic branch June 9, 2022 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic in parse_from_rfc2822 with overflowing date
2 participants