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

Add a resolve_components method to DateTimeFormat #1362

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

gregtatum
Copy link
Member

This is required for feature compatibility with ECMA-402. The backing
DateTimeFormat implementation needs to be able to return the resolved
components from the given options. These resolved components can differ
based on locale or the resolution algorithm.

Resolves #1361

This is required for feature compatibility with ECMA-402. The backing
DateTimeFormat implementation needs to be able to return the resolved
components from the given options. These resolved components can differ
based on locale or the resolution algorithm.
@@ -489,6 +492,183 @@ impl From<TimeZoneName> for Field {
}
}

/// Get the resolved components for a DateTimeFormat, via the PatternPlurals. In the case of
/// plurals resolve off of the required `other` pattern.
impl<'data> From<&PatternPlurals<'data>> for Bag {
Copy link
Member Author

Choose a reason for hiding this comment

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

The components::Bag is a little weird to return here, but seems more maintainable than creating a separate ResolvedComponents type, since the return information fully fit into the existing struct.

@sffc sffc self-requested a review December 6, 2021 21:55
Copy link
Member

@nordzilla nordzilla left a comment

Choose a reason for hiding this comment

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

This looks good to me.

Thanks for adding tests and documenting what is not yet implemented.

_ => Numeric::Numeric,
},
fields::Second::FractionalSecond => {
unimplemented!("fields::Second::FractionalSecond. #1360")
Copy link
Member

Choose a reason for hiding this comment

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

praise

Thanks for providing strings to all of the unimplemented!() macro calls, and also for adding issue numbers where relevant.

@gregtatum gregtatum merged commit 5c7c7fd into unicode-org:main Dec 15, 2021
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.

Provide the resolved components for a DateTimeFormat
3 participants