Skip to content

Conversation

@robertbastian
Copy link
Member

Currently we only support the r symbol for cyclic calendars, however nothing in the LDML says that it is only usable with cyclic calendars. This adds support for all other calendars.

///
/// Lunar calendars, like [`Hijri`](crate::cal::Hijri), drift quickly through the Gregorian year, so related Gregorian
/// years are frequently repeated.
pub fn related_gregorian(self) -> i32 {
Copy link
Member

Choose a reason for hiding this comment

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

given that it's allowed to be negative (no eras), this should be ISO year, yes? or gregorian extended year.

I agree that hte "ISO calendar" isn't the most consistent concept, but "ISO year" is much more well defined

Copy link
Member Author

Choose a reason for hiding this comment

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

CLDR calls it "related Gregorian" year

ISO is a format, Gregorian is a calendar. I will die on this hill

Copy link
Member

Choose a reason for hiding this comment

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

If that's what CLDR calls it fair enough.

Copy link
Member

Choose a reason for hiding this comment

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

Gregorian does not have signed years.

It has extended years; you could call it related_extended_gregorian but I don't think anyone wants that.

Plus, we already call it related_iso for cyclic years. You're the king of consistency.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm happy to deprecate any mentions of related_iso

Copy link
Member

Choose a reason for hiding this comment

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

ISO is a format

ISO-8601 defines a calendar system, not just a format.

Copy link
Member Author

Choose a reason for hiding this comment

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

it defines a string format for the proleptic Gregorian calendar

Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

It's in CLDR, but it seems to have footguns. We shouldn't add new things that have known footguns.

}
}

/// The Gregorian year in which this year started.
Copy link
Member

Choose a reason for hiding this comment

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

Observation: This produces surprising results for calendars with new years in the second half of the year, like Hebrew, Ethiopian, Coptic. It also means that multiple Hijri years will have the same related ISO year.

Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

We've been consistent about Gregorian meaning the calendar with eras and nonzero year numbers. Let's not muck it up

@robertbastian
Copy link
Member Author

It's in CLDR, but it seems to have footguns. We shouldn't add new things that have known footguns.

what's the footgun?

We've been consistent about Gregorian meaning the calendar with eras and nonzero year numbers. Let's not muck it up

related_gregorian_extended_year then. We've also generally tried to be consistent with CLDR.

@sffc
Copy link
Member

sffc commented Dec 18, 2025

It's in CLDR, but it seems to have footguns. We shouldn't add new things that have known footguns.

what's the footgun?

That there isn't a 1-to-1 mapping.

We've been consistent about Gregorian meaning the calendar with eras and nonzero year numbers. Let's not muck it up

related_gregorian_extended_year then. We've also generally tried to be consistent with CLDR.

I prefer related_iso but won't veto related_gregorian_extended_year.

Temporal uses ISO for this. It's literally encoded into the API: Temporal.Now.plainDateISO()

@robertbastian
Copy link
Member Author

That there isn't a 1-to-1 mapping.

The r symbol can be used to add additional context to a non-gregorian date. Yes you can format dd-MM-rr, but that's not a footgun, because you don't do that accidentally.

@robertbastian
Copy link
Member Author

Temporal uses ISO for this. It's literally encoded into the API: Temporal.Now.plainDateISO()

I consider ECMA's and Temporal's distinction between ISO and Gregorian a major flaw. I'd also like to point out that Temporal.PlainDate.year returns the extended/arithmetic year (even for Gregorian), and .eraYear returns the era year, so by Temporal logic this shouldn't be the extended Gregorian year, just the Gregorian year.

@sffc
Copy link
Member

sffc commented Dec 19, 2025

There were lengthy discussions in Temporal where we arrived at these designs, weighing lots and lots of tradeoffs. I could write it up but I have better things to spend my time on today.

@Manishearth
Copy link
Member

I don't really care about the name here. Self-consistency is a good motivator. I'd like to avoid deprecating things further just for naming reasons.

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.

3 participants