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

Fallback values for datetime errors #4851

Merged
merged 22 commits into from
May 6, 2024

Conversation

robertbastian
Copy link
Member

No description provided.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@robertbastian robertbastian changed the title Better fallback values for datetime errors Fallback values for datetime errors Apr 30, 2024
@robertbastian robertbastian requested review from sffc and removed request for nordzilla April 30, 2024 13:58
fmt

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@robertbastian robertbastian requested a review from sffc May 2, 2024 17:03
@robertbastian robertbastian requested a review from Manishearth as a code owner May 3, 2024 14:51
@Manishearth Manishearth removed their request for review May 3, 2024 17:43
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

I realized that it will be easier to review if I just download the code and make inline edits. I will push my suggestions to your branch.

Comment on lines 241 to 243
ds.get_symbol_for_era(l, &year.era)
.map(|e| e.unwrap_or(&year.era.0))
}) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think you don't need the extra map here. It should use the Err path in the match

Suggested change
ds.get_symbol_for_era(l, &year.era)
.map(|e| e.unwrap_or(&year.era.0))
}) {
ds.get_symbol_for_era(l, &year.era)
}) {

Copy link
Member Author

@robertbastian robertbastian May 4, 2024

Choose a reason for hiding this comment

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

get_symbol_for_era returns Result<Option<&str>>, so I was under the impression that the Option is an optimisation and not an error. If it's an error, why doesn't it return Result<&str>?

Copy link
Member

Choose a reason for hiding this comment

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

See the test I had to change. It was a mechanism to write out the era name fallback. TryWriteable is a better solution. Hmm, I think this trait is internal, so we could probably change it to return Result<&str>.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will address this in a follow-up

sffc
sffc previously approved these changes May 3, 2024
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

I approve with the additional changes I pushed to your branch.

sffc
sffc previously approved these changes May 3, 2024
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

Will wait for @robertbastian to review my changes and merge.

Comment on lines 241 to 243
ds.get_symbol_for_era(l, &year.era)
.map(|e| e.unwrap_or(&year.era.0))
}) {
Copy link
Member Author

@robertbastian robertbastian May 4, 2024

Choose a reason for hiding this comment

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

get_symbol_for_era returns Result<Option<&str>>, so I was under the impression that the Option is an optimisation and not an error. If it's an error, why doesn't it return Result<&str>?

.and_then(|ns| {
// We only support fixed field length for fractional seconds.
let FieldLength::Fixed(p) = length else {
return Err(Error::Pattern(
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Avoid using return in this function. Unclear what it returns from

@robertbastian robertbastian merged commit def81e6 into unicode-org:main May 6, 2024
30 checks passed
@robertbastian robertbastian deleted the lossy branch May 7, 2024 06:26
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.

None yet

2 participants