-
Notifications
You must be signed in to change notification settings - Fork 180
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
[datetime] Add support for width-aware noon and midnight DayPeriods #435
Comments
I am planning to work on this. |
Hi Erik! Thank you for picking it up! From this list: https://unicode.org/reports/tr35/tr35-dates.html#dfst-period We currently support a very very basic am/pm in https://github.com/unicode-org/icu4x/blob/master/components/provider/src/structs/dates.rs#L102 and use it in https://github.com/unicode-org/icu4x/blob/master/components/datetime/src/provider.rs#L195-L199 @sffc suggested that it may be worth separating our flexible periods since they are quite a bit more complex with their own rules and parsers etc. So, what we suggest to focus on for 0.2 is to get:
This will require a little bit of calculations for noon/midnight, but not that much, and mostly it's about adding the data to the right places. One design decision you may want to consider is whether it's worth separating day periods out to a separate data provider key in ICU4X data. The reason here is that constructor knows if day periods will be needed, so for all dates which don't use them we could save some memory and bandwidth by not loading them. @sffc, @mihnita - is that a good model to use? I know you talked about potentially adding methods to change display in place, but my hope is that we can still assume that if the constructor identified that dayperiods are not needed, instance mutations of the formatter cannot make it necessary. |
I talk about day periods a bit in #355. In my mind, the key question is, can day periods be deterministically computed from the time of day? From my discussions with Mark, Mihai, and others, it seems the answer is YES for Can we keep the discussion about whether to split day periods into their own data key in #257? |
Yep! @nordzilla do you have all necessary information to tackle this now? |
Yes, I believe so! I'll certainly have questions, but I'm starting work on it. |
I've run into my first roadblock where I have some questions: After adding the relevant symbols, I've been trying to generate new test data that includes When I try to generate the test data via
I'm going to pick up tomorrow with looking into if/how we can support optional symbols. Presumably if the I'm still very new to this code base, and entirely new to internationalization. If you have any insights or pointers, they would be much appreciated. |
Start with the spec: https://unicode.org/reports/tr35/tr35-dates.html#Day_Period_Rules
This data file is probably going to be useful; sorry for not flagging it sooner: |
The data file linked above (dayPeriods.json) will be useful for Basically, noon falls back to pm if the noon symbol is unavailable in the locale's data file, and midnight falls back to am if the midnight symbol is not available. |
This fits into ICU4X 0.2 roadmap (#239) under
DateTimeFormat
.The text was updated successfully, but these errors were encountered: