-
Notifications
You must be signed in to change notification settings - Fork 225
Remove generic CldrCalendar impl for Hijri and add update docs #7005
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
base: main
Are you sure you want to change the base?
Conversation
impl CldrCalendar for Hijri<hijri::UmmAlQura> { | ||
type YearNamesV1 = DatetimeNamesYearHijriV1; | ||
type MonthNamesV1 = DatetimeNamesMonthHijriV1; | ||
type SkeletaV1 = DatetimePatternsDateHijriV1; | ||
} |
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.
Note: This trait is very easy to implement in userland, easier than in 1.0. All you need to do is look at the menu of available data markers and pick the ones you want. If you have special needs, you can even mix and match stock data markers and custom data markers.
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.
nothing that involves the word data marker is easy for users in my experience
impl CldrCalendar for Hijri<hijri::UmmAlQura> { | ||
type YearNamesV1 = DatetimeNamesYearHijriV1; | ||
type MonthNamesV1 = DatetimeNamesMonthHijriV1; | ||
type SkeletaV1 = DatetimePatternsDateHijriV1; | ||
} |
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.
nothing that involves the word data marker is easy for users in my experience
/// Year information for a year that is specified as a cyclic year | ||
/// | ||
/// Knowing the cyclic year is typically not enough to pinpoint a date, however cyclic calendars | ||
/// don't typically use eras, so disambiguation can be done by saying things like "Year 甲辰 (2024)" |
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.
this is an out-struct, so it doesn't need to "pinpoint" a date
I also don't like the phrasing of "disambiguation can be done by saying things like"
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.
These are pre-existing docs that I moved. They were previously on YearInfo::Cyclic
.
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 but this is an "update docs" PR so let's update them
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.
The cyclic year is insufficient to fully specify a date, and cyclic calendars typically do not use eras. In cases where a date needs to be unambiguously specified, one can do things like (...) using the
related_iso
field.
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.
The month is also insufficient to fully specify a date, yet we don't put a disclaimer that you need to add a different field if you're doing formatting.
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.
This type contains the information to fully specify a year (it has a related_iso
field).
What the comment is trying to explain is how to display this type "in cases where a date needs to be unambiguously specified", which I really don't think should be explained in this crate, as these cases are very locale-dependent. We also don't explain how EraYear
should be displayed.
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 think it's good context as to why there's a related_iso field
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.
Then move this to the field? Link to other explanations like we do for extended year?
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.
Fine by me
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.
Fine by me
/// This calendar has a small, fixed set of eras with numeric years, this stores the era names in chronological order. | ||
/// | ||
/// See FormattableEra for a definition of what chronological order is in this context. | ||
/// See [`EraYear`](icu_calendar::types::EraYear) for a definition of what chronological order is in this context. |
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.
EraYear
does not define a "chronological order". You probably want to point to the era_index
field, which is definitely not chronological
/// - The era and year names are loaded from [`Self::YearNamesV1`] and accessed based on [`YearInfo`] | ||
/// - The month name is loaded from [`Self::MonthNamesV1`] and accessed based on [`MonthInfo`] |
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.
this is really internal, I'd rather not have users deal with it
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.
This is the public interface between YearInfo/YearNames and MonthInfo/MonthNames. It ought to be documented. Users need to worry about it only if they're implementing a custom calendar.
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.
You say public interface, I say unstable provider code.
Also, for reference, the justification behind not unifying the formatting is given in #6963 (comment), under "Hijri formatting". Specifically, CLDR may choose to have divergent formatting for these calendars. When discussing that, I was unconvinced of arguments like "umm al-qura may mandate a different month name" (that, to me, is a regional concern), however there is a good argument to be made for regions with multiple calendars tacking disambiguators on their format strings, e.g. something like Also, either way I think we should not unify formatting unless CLDR commits to the formatting being the same. Too bad we don't have specialization; I'd have been very comfortable with unified formatting under specialization. |
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.
(Generally in favor of this approach, at least for 2.1)
Co-authored-by: Robert Bastian <[email protected]>
Yes, I'm totally okay with having a default formatting impl, but it must be overridable. That's non-negotiable |
I would not object to exporting a macro like |
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.
Users with a custom Hijri should implement CldrCalendar themselves
It is not actually possible to implement CldrCalendar
for Hijri<CustomRules>
due to the orphan rule. You'd need a newtype for which you'd have to implement Calendar
as well. It's a lot of boilerplate and unstable code.
I'm fine with reverting this for now and just not offering this functionality, but I would still like to have the generic implementation in the future.
there is a good argument to be made for regions with multiple calendars tacking disambiguators on their format strings, e.g. something like Ramadan 5, 1447 [Umm al-Qura].
Such disambiguators will not necessarily be in the skeleton. Another solution would be to introduce a new calendar field, or put them in the era name.
/// This calendar has a small, fixed set of eras with numeric years, this stores the era names in chronological order. | ||
/// | ||
/// See [`EraYear`](icu_calendar::types::EraYear) for a definition of what chronological order is in this context. | ||
/// This calendar has a small, fixed set of eras with numeric years. Eras are stored |
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.
keep the first sentence of a doc comment as its own paragraph.
I think we should introduce a new trait in It would be nice to have default associated types on that, so clients can just say |
Good point
Yep, I think this direction is one we should explore. It's an example of why I don't want to rush into shipping these things. |
This is mostly replaced by #7028 but there are some docs that might be worth resurrecting. |
#6963
Users with a custom Hijri should implement CldrCalendar themselves. I don't want to commit to a single immutable set of patterns and display names for eternity.