-
Notifications
You must be signed in to change notification settings - Fork 226
Add precise definitions and limits for all calendars #7123
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,13 @@ impl GregorianYears for CeBce { | |
/// # Month codes | ||
/// | ||
/// This calendar supports 12 solar month codes (`"M01" - "M12"`) | ||
/// | ||
/// # Precise definition and limits | ||
/// | ||
/// This calendar is defined algorithmically as a solar calendar that has 12 months, with a leap day in the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this repeats things that are already said in either the introductory paragraph or the Historical accuracy section There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I cleaned thsi up with Chinese but didn't do that elsewhere. I think duplication is somewhat okay in the Gregorian case but I can refer to the past section. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: this definition does not fully define the calendar (it does not specify all month lenghts). I do find it kind of pointless, however, to try to provide a precise definition for this calendar, it's not like there are multiple competing variants floating around. we already link to Wikipedia for a full discussion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I wasn't quite sure of how precise to do these. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for simple calendars like Gregorian, Coptic, Julian, Ethiopian, it suffices to say that they are proleptic if we don't say that yet not every calendar needs a "Precise definition and limits" sections if we already have good docs |
||
/// 2nd month every 4 and 400 years (but not every 100 years). As of 2025 it is a widely used civil calendar | ||
/// in most countries, including the UN. The Gregorian calendar was adopted gradually starting in the 1500s, | ||
/// this calendar extends proleptically before that. | ||
#[derive(Copy, Clone, Debug, Default)] | ||
#[allow(clippy::exhaustive_structs)] // this type is stable | ||
pub struct Gregorian; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,16 @@ mod ummalqura_data; | |
/// | ||
/// This calendar is a pure lunar calendar with no leap months. It uses month codes | ||
/// `"M01" - "M12"`. | ||
/// | ||
/// # Precise definition and limits | ||
/// | ||
/// This calendar generically covers any pure lunar calendar used liturgically in Islam, | ||
/// with 12 months each of length 29 or 30, with an epoch intended to mark the Hijrah in 622 CE. | ||
Comment on lines
+53
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: I'm fine saying that the epoch is the Hijrah, but I thought we previously said we needn't make that commitment, which is why we added ECMA reference year functions to the hijri::Rules trait. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think from a calendrical definition perspective saying the epoch is Hijrah is probably good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need that actually, because |
||
/// | ||
/// In practice, this calendar can be backed by a precise algorithm, a lookup in official tables, | ||
/// astronomical simulation, or pure observation. | ||
/// | ||
/// Further details can be found on individual calendar types. | ||
#[derive(Clone, Debug, Default, Copy)] | ||
#[allow(clippy::exhaustive_structs)] // newtype | ||
pub struct Hijri<S>(pub S); | ||
|
@@ -111,6 +121,14 @@ pub trait Rules: Clone + Debug + crate::cal::scaffold::UnstableSealed { | |
/// | ||
/// This corresponds to the `"islamic-rgsa"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier) | ||
/// if constructed with [`Hijri::new_simulated_mecca()`]. | ||
/// | ||
/// # Precise definition and limits | ||
/// | ||
/// This calendar simulates the lunar cycle for a given location. This currently | ||
/// simulates the calendar for all time using the same calculations, but we may | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it falls back to tabular when invariants are violated already |
||
/// in the future introduce approximations for non-modern dates. | ||
/// | ||
/// The precise behavior of this calendar for any and all dates may change in the future. | ||
#[derive(Copy, Clone, Debug)] | ||
pub struct AstronomicalSimulation { | ||
pub(crate) location: SimulatedLocation, | ||
|
@@ -227,15 +245,21 @@ impl Rules for AstronomicalSimulation { | |
|
||
/// [`Hijri`] [`Rules`] for the [Umm al-Qura](https://en.wikipedia.org/wiki/Islamic_calendar#Saudi_Arabia's_Umm_al-Qura_calendar) calendar. | ||
/// | ||
/// This corresponds to the `"islamic-umalqura"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier). | ||
/// | ||
/// # Precise definition and limits | ||
/// | ||
/// This calendar represents the Umm al-Qura calendar defined by the Kingdom of Saudi Arabia. | ||
/// | ||
/// From the start of 1300 AH (1882-11-12 ISO) to the end of 1600 AH (2174-11-25 ISO), this | ||
/// `Rules` implementation uses Umm al-Qura month lengths obtained from | ||
/// [KACST](https://kacst.gov.sa/). Outside this range, this implementation falls back to | ||
/// [`TabularAlgorithm`] with [`TabularAlgorithmLeapYears::TypeII`] and [`TabularAlgorithmEpoch::Friday`]. | ||
/// | ||
/// 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). | ||
/// The precise behavior of this calendar may change in the future if: | ||
/// - New ground truth is established by published government sources | ||
/// - We decide to tweak the simplified calculation | ||
/// - We decide to expand or reduce the range where we are handling past dates. | ||
#[derive(Copy, Clone, Debug, Default)] | ||
#[non_exhaustive] | ||
pub struct UmmAlQura; | ||
|
@@ -311,6 +335,11 @@ impl Rules for UmmAlQura { | |
/// | ||
/// 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. | ||
/// | ||
/// # Precise definition and limits | ||
/// | ||
/// This calendar is defined algorithmically based on the algorithm selected by the choice of [`TabularAlgorithmLeapYears`], | ||
/// and the epoch selected by the choice of [`TabularAlgorithmEpoch`]. | ||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] | ||
pub struct TabularAlgorithm { | ||
pub(crate) leap_years: TabularAlgorithmLeapYears, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,13 @@ use tinystr::tinystr; | |
/// # Month codes | ||
/// | ||
/// This calendar supports 12 solar month codes (`"M01" - "M12"`) | ||
/// | ||
/// # Precise definition and limits | ||
/// | ||
/// This calendar is defined algorithmically as a solar calendar that has 12 months, as used alongside the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not a very precise definition. month lengths? leap years? |
||
/// Gregorian calendar by the Government of India by the name "Śaka calendar" as of publication date of this crate. | ||
/// | ||
/// The Śaka calendar was introduced in 1957, but this calendar extends proleptically before that. | ||
#[derive(Copy, Clone, Debug, Hash, Default, Eq, PartialEq, PartialOrd, Ord)] | ||
#[allow(clippy::exhaustive_structs)] // this type is stable | ||
pub struct Indian; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,11 @@ use tinystr::tinystr; | |
/// # Month codes | ||
/// | ||
/// This calendar supports 12 solar month codes (`"M01" - "M12"`) | ||
/// | ||
/// # Precise definition and limits | ||
/// | ||
/// This calendar is defined algorithmically as a solar calendar that is identical to the proleptic Gregorian calendar | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the same as the first paragraph |
||
/// in everything except the way eras are handled. | ||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
#[allow(clippy::exhaustive_structs)] // this type is stable | ||
pub struct Iso; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,12 @@ use tinystr::tinystr; | |
/// # Month codes | ||
/// | ||
/// This calendar supports 12 solar month codes (`M01` - `M12`) | ||
/// | ||
/// # Precise definition and limits | ||
/// | ||
/// This calendar is defined algorithmically as a solar calendar that is identical to the proleptic Gregorian calendar in everything | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is already said in the first two paragraphs |
||
/// except year numbering. This is the civil calendar used in Japan from 1873, this calendar extends proleptically | ||
/// before that. | ||
#[derive(Clone, Debug, Default)] | ||
pub struct Japanese { | ||
eras: DataPayload<CalendarJapaneseModernV1>, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,12 @@ use tinystr::tinystr; | |
/// # Month codes | ||
/// | ||
/// This calendar supports 12 solar month codes (`"M01" - "M12"`) | ||
/// | ||
/// # Precise definition and limits | ||
/// | ||
/// This calendar is defined algorithmically as a solar calendar with a leap month every 4 years, as was used | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is already explained in previous paragraphs, and this is not very exact There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think specifying the year it was used in the Roman empire is quite exact, and the best we can do for a historical calendar. Do you have another suggestion? |
||
/// by the Roman empire in 4 CE. That algorithm is extended proleptically before and after its period of use. | ||
/// | ||
#[derive(Copy, Clone, Debug, Hash, Default, Eq, PartialEq, PartialOrd, Ord)] | ||
#[allow(clippy::exhaustive_structs)] // this type is stable | ||
pub struct Julian; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,20 @@ use calendrical_calculations::rata_die::RataDie; | |
/// # Month codes | ||
/// | ||
/// This calendar supports 12 solar month codes (`"M01" - "M12"`) | ||
/// | ||
/// # Precise definition and limits | ||
/// | ||
/// This calendar is defined as a solar calendar which uses the astronomical vernal equinox as its new year, and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how many months? how long? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary to be that precise in each calendar? Expressing some characteristics and a polity where it is official is pretty unambiguous. |
||
/// is the official calendar of the Islamic Republic of Iran as of the publication date of this crate. This calendar was introduced in Iran in 1925, | ||
/// but the astronomical calculations are extended proleptically before that. | ||
/// | ||
/// As these are pure solar computations, the astronomical calculations can be treated as a relatively | ||
/// precise algorithm and there is much less need to match ground truth. Nevertheless, in the event that the calculations | ||
/// disagree with the ground truth of calendar usage in Iran, the ground truth will prevail. | ||
/// | ||
/// The underlying implementation uses a cyclic approximation with overrides to match the precise astronomic calculations | ||
/// for the years 1178-3500 AP. Outside of that range one can expect this calendar implementation to no longer | ||
/// accurately match the astronomical calculations. | ||
#[derive(Copy, Clone, Debug, Default, Hash, Eq, PartialEq, PartialOrd, Ord)] | ||
#[allow(clippy::exhaustive_structs)] | ||
pub struct Persian; | ||
|
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.
putting the whole docs under this heading feels kind of pointless
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? That's all of what the docs are about in this case.
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 could put a "precise defintion" heading at the top of pretty much every doc comment. if it doesn't separate from some other heading it's pointless