-
Notifications
You must be signed in to change notification settings - Fork 220
Implement Ethopian in terms of Coptic #6952
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
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. |
type DateInner = GregorianDateInner; | ||
type DateInner = IsoDateInner; |
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.
Issue: I think we have the GregorianDateInner
type because it's public API and we don't want to lock into a specific representation
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 unstable public API
- Buddhist already uses
IsoDateInner
without wrapping
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.
Associated types are not unstable; you can get DateInners from various places and you might have saved them in a variable. I know I do that. I imagine temporal_rs or some other client who integrates deeply with icu_calendar might do that.
If Buddhist doesn't have a newtype, that's a bug
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.
associated types are obtained only from the Calendar
trait, which is unstable
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 Sealed, not unstable. We can't just go and change the signatures of functions on the trait. It is sealed so we can add new functions.
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.
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.
UnstableSealed
is the same as Sealed
except it means people can still implement it if they are okay with the trait changing. It's about implementers, not users
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.
fact is we document this as being allowed to break semver
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.
icu::calendar::Calendar
is a trait that is sealed, and it is also a trait that people can construct and call methods from. It is implemented by a dozen public types in the crate. This is not controversial.
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 intent of that documentation was that this trait is unstable to implement. The trait implementors are not going to have the same banner.
We should maybe fix the banner to be clearer about calling the trait, but at the moment a person looking at the docs for an individual calendar will not know that the underlying types are stable.
So this is not unstable public API, and I don't think that's a matter that we should continue to debate.
Now, that said, I am somewhat okay with minor breaking stuff around this provided we do not remove any names from the crate (we add type aliases, like we did in Dangi). We probably should have started with type aliases from the get-go, or started with individual newtypes, to give us freedom to change things.
So if we retain a deprecated GregorianDateInner type alias, that's great.
impl crate::cal::scaffold::UnstableSealed for Ethiopian {} | ||
impl Calendar for Ethiopian { | ||
type DateInner = EthiopianDateInner; | ||
type DateInner = CopticDateInner; |
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.
Issue: This should stay as EthiopianDateInner
but that type could change to be a newtype over CopticDateInner
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.
why
if era_style == EthiopianEraStyle::AmeteAlem { | ||
year -= INCARNATION_OFFSET; | ||
} |
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.
Issue: I was also looking at this code last week, and I think this operation seems wrong. I think it should be
if era_style == EthiopianEraStyle::AmeteAlem { | |
year -= INCARNATION_OFFSET; | |
} | |
if era_style == EthiopianEraStyle::AmeteMihret { | |
year += INCARNATION_OFFSET; | |
} |
because it seems like the year was stored in Amete Alem for both era styles. In your case, you still need this change if you are trying to store the year in Anno Martyrum.
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 seems unrelated to this PR
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 guess it's fine if the tests still pass
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 code path doesn't seem to be covered by tests. however I'm not touching the alem vs mihret logic here, so it should be fixed and tested in a different PR
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 something we should fix in the from_fields PR, really, or separately.
components/calendar/src/cal/roc.rs
Outdated
type DateInner = RocDateInner; | ||
type DateInner = IsoDateInner; |
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.
Issue: Keep the newtype
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 didn't address my feedback
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.
.
Plumbing |
Technically I think adding a type alias would also suffice from a semver perspective, but I still strongly prefer the newtypes. (Not just here but also ideally in Chinese and Hijri) |
It's technically not fully good from a semver perspective but the semver risk is very slight: it only matters for people doing But as with the Chinese/Hijri stuff, I'm okay with this level of breakage. We should not remove names from the crate; so we should introduce deprecated aliases. |
5c00fdc
to
fa7a90c
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.
Also, let's wait to merge this until I merge Date::from_fields. I've already needed to rebase it on top of Hijri and Chinese, which was fine because those PRs blocked other work, but this PR strikes me as one that could wait a couple of days and be harmless, and it's small enough that it can be rebased on top of Date::from_fields.
/// The inner date type used for representing [`Date`]s of [`Ethiopian`]. See [`Date`] and [`Ethiopian`] for more details. | ||
/// | ||
/// The year is stored as Amete Alem year | ||
#[allow(missing_docs)] // not actually public |
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: Let's not add #[missing_docs]
. I would like this type to be public but have no methods on it.
It might be a bug that this type isn't exported, since it can be accessed by Coptic::DateInner
.
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'm pretty sure it's intended that these types are only nameable as associated types. If they don't have a public API, why would they need docs.
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 a very short line of docs is good here. We don't need more.
Yes, these are mostly assoc types, but people might stumble upon them via search. We should probably improve the docs for that case (the current docs aren't great!), but we shouldn't remove 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 current docs aren't great!
the current docs are not public, because this is not a public type
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.
ah, huh. That's fine 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.
Surprised the lint fires.
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.
r+ on approach, would also prefer from_fields to land first.
/// The inner date type used for representing [`Date`]s of [`Ethiopian`]. See [`Date`] and [`Ethiopian`] for more details. | ||
/// | ||
/// The year is stored as Amete Alem year | ||
#[allow(missing_docs)] // not actually public |
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 a very short line of docs is good here. We don't need more.
Yes, these are mostly assoc types, but people might stumble upon them via search. We should probably improve the docs for that case (the current docs aren't great!), but we shouldn't remove them.
if era_style == EthiopianEraStyle::AmeteAlem { | ||
year -= INCARNATION_OFFSET; | ||
} |
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 something we should fix in the from_fields PR, really, or separately.
One other thing is missing from the PR: why? For Hijri, there are a lot of different sightings, and the Hijri trait offers convenient functionality utilizing the YearInfo, like arithmetic, ISO conversion, etc., which would be hard to replicate in userland. Same with Chinese. But I don't see the same motivation applying to ISO-based calendars. You don't gain any functionality by plugging in your own epoch. Do you? |
This deduplicates code that the compiler will not necessarily know to deduplicated (because the diffs are at the very bottom, in Storing the Ethiopian year as a Coptic year is also way clearer wrt which era is used internally. |
These are the same calendar, just using different eras.
This is the same situation as Gregorian, Iso, Buddhist, Japanese, and Roc being the same calendar using different eras.
We might want to make these calendars generic in the future, and have something like
Coptic<CopticEra>
,Coptic<EthiopianEraStyle>
,Gregorian<JapaneseEras>
,Gregorian<Iso>
, etc.