Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions components/calendar/src/any_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,40 +683,76 @@ impl<C: AsCalendar<Calendar = AnyCalendar>> Date<C> {
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum AnyCalendarKind {
/// The kind of a [`Buddhist`] calendar
///
/// This corresponds to the `"buddhist"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Copy link
Member

Choose a reason for hiding this comment

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

these should link to the CalendarAlgorithm variant, which already links to the LDML

Copy link
Member Author

Choose a reason for hiding this comment

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

https://unicode-org.github.io/icu4x/rustdoc/icu/calendar/preferences/enum.CalendarAlgorithm.html

Yeah but the exact correspondence isn't documented there either.

Happy to add docs there too but I don't actually think we should cross reference here: I've been annoyed at the number of clicks it takes to figure this out each time and it's fine to be repetitive in docs.

Buddhist,
/// The kind of a [`Chinese`] calendar
///
/// This corresponds to the `"chinese"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Chinese,
/// The kind of a [`Coptic`] calendar
///
/// This corresponds to the `"coptic"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Coptic,
/// The kind of a [`Dangi`] calendar
///
/// This corresponds to the `"dangi"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Dangi,
/// The kind of an [`Ethiopian`] calendar, with Amete Mihret era
///
/// This corresponds to the `"ethiopic"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Ethiopian,
/// The kind of an [`Ethiopian`] calendar, with Amete Alem era
///
/// This corresponds to the `"ethioaa"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
EthiopianAmeteAlem,
/// The kind of a [`Gregorian`] calendar
///
/// This corresponds to the `"gregory"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Gregorian,
/// The kind of a [`Hebrew`] calendar
///
/// This corresponds to the `"hebrew"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Hebrew,
/// The kind of a [`Indian`] calendar
///
/// This corresponds to the `"indian"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Indian,
/// The kind of an [`HijriTabular`] calendar using [`HijriTabularLeapYears::TypeII`] and [`HijriTabularEpoch::Friday`]
///
/// This corresponds to the `"islamic-civil"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
HijriTabularTypeIIFriday,
/// The kind of an [`HijriSimulated`], Mecca calendar
///
/// This corresponds to the `"islamic-rgsa"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
HijriSimulatedMecca,
Copy link
Member

@sffc sffc Oct 14, 2025

Choose a reason for hiding this comment

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

Observation: we have islamic-rgsa in AnyCalendarKind? (I know we discuss this at great length but I'm still surprised to see it here)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it's not used by Temporal but it's there. Probably wouldn't have it if we didn't.

I recently tweaked temporal_rs so that it will discard rgsa inputs.

/// The kind of an [`HijriTabular`] calendar using [`HijriTabularLeapYears::TypeII`] and [`HijriTabularEpoch::Thursday`]
///
/// This corresponds to the `"islamic-tbla"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
HijriTabularTypeIIThursday,
/// The kind of an [`HijriUmmAlQura`] calendar
///
/// This corresponds to the `"islamic-umalqura"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
HijriUmmAlQura,
/// The kind of an [`Iso`] calendar
///
/// This corresponds to the `"iso8601"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Iso,
/// The kind of a [`Japanese`] calendar
///
/// This corresponds to the `"japanese"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Japanese,
/// The kind of a [`JapaneseExtended`] calendar
///
/// This corresponds to the `"japanext"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
JapaneseExtended,
/// The kind of a [`Persian`] calendar
///
/// This corresponds to the `"persian"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Persian,
/// The kind of a [`Roc`] calendar
///
/// This corresponds to the `"roc"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Roc,
}

Expand Down
2 changes: 2 additions & 0 deletions components/calendar/src/cal/buddhist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use tinystr::tinystr;
///
/// This type can be used with [`Date`] to represent dates in this calendar.
///
/// This corresponds to the `"buddhist"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
///
/// [cal]: https://en.wikipedia.org/wiki/Thai_solar_calendar
///
/// # Era codes
Expand Down
3 changes: 3 additions & 0 deletions components/calendar/src/cal/chinese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ mod simple;
///
/// This type can be used with [`Date`] to represent dates in the Chinese calendar.
///
/// This corresponds to the `"chinese"` and `"dangi"` [CLDR calendars](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier)
/// respectively, when used with the [`China`] and [`Korea`] [`Rules`] types.
///
/// # Months
///
/// The Chinese calendar is an astronomical calendar which uses the phases of the moon to track months.
Expand Down
2 changes: 2 additions & 0 deletions components/calendar/src/cal/coptic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ use tinystr::tinystr;
///
/// This type can be used with [`Date`] to represent dates in this calendar.
///
/// This corresponds to the `"coptic"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
///
/// [Coptic calendar]: https://en.wikipedia.org/wiki/Coptic_calendar
///
/// # Era codes
Expand Down
3 changes: 3 additions & 0 deletions components/calendar/src/cal/ethiopian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ pub enum EthiopianEraStyle {
/// It can be constructed in two modes: using the Amete Alem era scheme, or the Amete Mihret era scheme (the default),
/// see [`EthiopianEraStyle`] for more info.
///
/// This corresponds to the `"ethiopic"` and `"ethioaa"` [CLDR calendars](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier),
/// with `"ethiopic"` being for [`EthiopianEraStyle::AmeteMihret`]
///
/// [Ethiopian calendar]: https://en.wikipedia.org/wiki/Ethiopian_calendar
///
/// # Era codes
Expand Down
2 changes: 2 additions & 0 deletions components/calendar/src/cal/gregorian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ impl GregorianYears for CeBce {
/// the mean siderial year, so this calendar drifts 1 day in ~7700 years with respect
/// to the seasons.
///
/// This corresponds to the `"gregory"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
///
/// # Historical accuracy
///
/// This type implements the [*proleptic* Gregorian calendar](
Expand Down
2 changes: 2 additions & 0 deletions components/calendar/src/cal/hebrew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use calendrical_calculations::rata_die::RataDie;
///
/// This calendar is the _civil_ Hebrew calendar, with the year starting at in the month of Tishrei.
///
/// This corresponds to the `"hebrew"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
///
/// # Era codes
///
/// This calendar uses a single era code `am`, Anno Mundi. Dates before this era use negative years.
Expand Down
11 changes: 11 additions & 0 deletions components/calendar/src/cal/hijri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ mod ummalqura_data;
///
/// This type supports only variants where months are either 29 or 30 days.
///
/// This corresponds to various `"islamic-*"` [CLDR calendars](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier),
/// see the individual implementors of [`Rules`] ([`TabularAlgorithm`], [`UmmAlQura`], [`AstronomicalSimulation`]) for more information.
///
/// # Era codes
///
/// This calendar uses two era codes: `ah`, and `bh`, corresponding to the Anno Hegirae and Before Hijrah eras
Expand Down Expand Up @@ -101,6 +104,9 @@ pub trait Rules: Clone + Debug + crate::cal::scaffold::UnstableSealed {
/// These simulations are unofficial and are known to not necessarily match sightings
/// on the ground. Unless you know otherwise for sure, instead of this variant, use
/// [`UmmAlQura`], which uses the results of KACST's Mecca-based calculations.
///
/// This corresponds to the `"islamic-rgsa"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier)
/// if constructed with [`Hijri::new_simulated_mecca()`].
#[derive(Copy, Clone, Debug)]
pub struct AstronomicalSimulation {
pub(crate) location: SimulatedLocation,
Expand Down Expand Up @@ -225,6 +231,8 @@ impl Rules for AstronomicalSimulation {
///
/// Future versions of this crate may extend the range that uses month length data from the
/// calendar authority.
///
/// This corresponds to the `"islamic-umalqura"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
#[derive(Copy, Clone, Debug, Default)]
#[non_exhaustive]
pub struct UmmAlQura;
Expand Down Expand Up @@ -294,6 +302,9 @@ impl Rules for UmmAlQura {
/// See [`TabularAlgorithmEpoch`] and [`TabularAlgorithmLeapYears`] for customization.
///
/// The most common version of these rules uses [`TabularAlgorithmEpoch::Friday`] and [`TabularAlgorithmLeapYears::TypeII`].
///
/// When constructed with [`TabularAlgorithmLeapYears::TypeII`], and either [`TabularAlgorithmEpoch::Friday`] or [`TabularAlgorithmEpoch::Thursday`],
/// this corresponds to the `"islamic-civil"` and `"islamic-tbla"` [CLDR calendars](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier) respectively.
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
pub struct TabularAlgorithm {
pub(crate) leap_years: TabularAlgorithmLeapYears,
Expand Down
2 changes: 2 additions & 0 deletions components/calendar/src/cal/indian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use tinystr::tinystr;
///
/// This type can be used with [`Date`] to represent dates in this calendar.
///
/// This corresponds to the `"indian"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
///
/// # Era codes
///
/// This calendar uses a single era code: `shaka`, with Śaka 0 being 78 CE. Dates before this era use negative years.
Expand Down
2 changes: 2 additions & 0 deletions components/calendar/src/cal/iso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use tinystr::tinystr;
/// This calendar is identical to the [`Gregorian`](super::Gregorian) calendar,
/// except that it uses a single `default` era instead of `bce` and `ce`.
///
/// This corresponds to the `"iso8601"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
Copy link
Member

Choose a reason for hiding this comment

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

issue: I'm not sure about this. while we currently resolve the CalendarAlgorithm::Iso8601 to AnyCalendar::Iso, I don't think that's quite the same on the CLDR level. -u-ca-iso8601 is meant to be a Gregorian format that uses YMD ordering in the skeletons.

Copy link
Member Author

@Manishearth Manishearth Oct 14, 2025

Choose a reason for hiding this comment

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

Yeah, I was unsure of that part. Can remove this snippet.

Temporal considers this to mean a generally useful ISO calendar.

///
/// # Era codes
///
/// This calendar uses a single era: `default`
Expand Down
4 changes: 4 additions & 0 deletions components/calendar/src/cal/japanese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use tinystr::tinystr;
///
/// This type can be used with [`Date`] to represent dates in this calendar.
///
/// This corresponds to the `"japanese"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
///
/// [Japanese calendar]: https://en.wikipedia.org/wiki/Japanese_calendar
///
/// # Era codes
Expand Down Expand Up @@ -52,6 +54,8 @@ pub struct Japanese {
///
/// This type can be used with [`Date`] to represent dates in this calendar.
///
/// This corresponds to the `"japanext"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
///
/// [Japanese calendar]: https://en.wikipedia.org/wiki/Japanese_calendar
///
/// # Era codes
Expand Down
2 changes: 2 additions & 0 deletions components/calendar/src/cal/persian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use calendrical_calculations::rata_die::RataDie;
///
/// This type can be used with [`Date`] to represent dates in this calendar.
///
/// This corresponds to the `"persian"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
///
/// # Era codes
///
/// This calendar uses a single era code `ap` (aliases `sh`, `hs`), with Anno Persico/Anno Persarum starting the year of the Hijra. Dates before this era use negative years.
Expand Down
2 changes: 2 additions & 0 deletions components/calendar/src/cal/roc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use tinystr::tinystr;
/// The ROC calendar should not be confused with the Chinese traditional lunar calendar
/// (see [`Chinese`](crate::cal::Chinese)).
///
/// This corresponds to the `"roc"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
///
/// # Era codes
///
/// This calendar uses two era codes: `roc`, corresponding to years in the 民國 era (CE year 1912 and
Expand Down