-
Notifications
You must be signed in to change notification settings - Fork 184
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
Refactor YearInfo to separate cyclic/Temporal/Formatting eras #5509
Conversation
3540469
to
02def68
Compare
02def68
to
43a4175
Compare
9b0f89c
to
5693d75
Compare
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 the main point of splitting Month/FormattableMonth and Year/FormattableYear is that the month codes and era codes are in different namespaces.
For example:
- Hebrew month code is "M06" for Temporal but "M06L" for data
- Islamic era code is the Islamic calendar name for Temporal but could be anything for data
I wonder if maybe the right design is, rather than splitting Year/FormattableYear, to just make a struct with a field for both namespaces of codes?
components/calendar/src/types.rs
Outdated
pub related_iso: Option<i32>, | ||
/// 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)" | ||
Cyclic(NonZeroU8, i32), |
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.
Can you explain why the cyclic year is NonZeroU8? Is it just because Chinese and Dangi count from 1 to 60?
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.
It's what it was before.
People don't really use zeroes in calendar systems.
components/calendar/src/types.rs
Outdated
} | ||
} | ||
} | ||
|
||
impl FormattableYear { | ||
/// Construct a new Year given an era and number | ||
pub fn new_era(extended_year: i32, era: TinyStr16, number: i32) -> Self { |
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.
Nit: I think this should probably take Era
not TinyStr16
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 mostly gets us slightly cleaner ctor calls everywhere
I think there were some other reasons too, things were diverging over time. I'm not opposed to keeping these merged, but perhaps we can discuss this in more depth later today. |
d411e61
to
c58ae78
Compare
159bfaa
to
5abf6a4
Compare
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.
Good work! Lots of meticulous changes
components/calendar/src/ethiopian.rs
Outdated
}); | ||
} | ||
1 - year | ||
} else if era.0 == tinystr!(16, "mundi") || era.0 == tinystr!(16, "ethiopicaa") { |
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.
Nit: ethioaa
not ethiopicaa
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 isn't what the spec says
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.
Updated, but the spec should also be fixed, then.
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.
tc39/proposal-intl-era-monthcode#19 , seems like there already was a PR to fix this
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.
Yes, I thought that PR was merged long ago but no one ever hit the button.
6e7a842
to
1ab0166
Compare
Part of #3821
This produces a more precise YearInfo that produces multiple era types, and separates out cyclic from non-cyclic. Consumers of this data get to be more specific about the fallback behavior they want when asking for eras from cyclic calendars (etc).