Skip to content

Commit fd7738c

Browse files
committed
Add precise definitions and limits for all calendars
1 parent 8371b92 commit fd7738c

File tree

13 files changed

+148
-2
lines changed

13 files changed

+148
-2
lines changed

components/calendar/src/cal/buddhist.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ use tinystr::tinystr;
3131
/// # Month codes
3232
///
3333
/// This calendar supports 12 solar month codes (`"M01" - "M12"`)
34+
///
35+
/// # Precise definition and limits
36+
///
37+
/// This calendar is defined algorithmically as a solar calendar that is identical to the proleptic Gregorian calendar in everything
38+
/// except year numbering. This is the civil calendar used in Thailand from the year 1912 onwards,
39+
/// but the algorithm is extended proleptically before that.
3440
#[allow(clippy::exhaustive_structs)] // this type is stable
3541
pub struct Buddhist;
3642

components/calendar/src/cal/chinese.rs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ mod simple;
8484
///
8585
/// This calendar is currently in a preview state: formatting for this calendar is not
8686
/// going to be perfect.
87+
///
88+
/// # Precise definition and limits
89+
///
90+
/// This calendar generically covers any East Asian-style lunisolar calendar with twelve months, and leap months possible
91+
/// after any month. Individual variants [`China`] and [`Korea`] contain more information.
8792
#[derive(Clone, Debug, Default, Copy, PartialEq, Eq, PartialOrd, Ord)]
8893
#[allow(clippy::exhaustive_structs)] // newtype
8994
pub struct LunarChinese<X>(pub X);
@@ -141,11 +146,17 @@ pub trait Rules: Clone + core::fmt::Debug + crate::cal::scaffold::UnstableSealed
141146

142147
/// The [`Rules`] used in China.
143148
///
144-
/// This type agrees with the official data published by the
149+
/// # Precise definition and limits
150+
///
151+
/// This calendar is intended to represent the traditional Chinese lunar calendar as used
152+
/// officially in the People's Republic of China as of 2025. This takes a best-effort approach
153+
/// to match past and future dates as used in the region for the year 1900 onwards.
154+
///
155+
/// This calendar agrees with the official data published by the
145156
/// [Purple Mountain Observatory for the years 1900-2025], as well as with
146157
/// the data published by the [Hong Kong Observatory for the years 1901-2100].
147158
///
148-
/// For years since 1912, this uses the [GB/T 33661-2017] rules.
159+
/// For years since 1912, this uses official the [GB/T 33661-2017] rules.
149160
/// As accurate computation is computationally expensive, years until
150161
/// 2100 are precomputed, and after that this type regresses to a simplified
151162
/// calculation. If accuracy beyond 2100 is required, clients
@@ -158,6 +169,12 @@ pub trait Rules: Clone + core::fmt::Debug + crate::cal::scaffold::UnstableSealed
158169
/// required before 1900, clients can implement their own [`Rules`] type
159170
/// using data such as from the excellent compilation by [Yuk Tung Liu].
160171
///
172+
/// The precise behavior of this calendar may change in the future if:
173+
/// - The ground truth in China changes, either through published government sources or most almanacs
174+
/// - Future data is published that we wish to incorporate
175+
/// - We decide to tweak the simplified calculation
176+
/// - We decide to expand the range where we are handling past dates.
177+
///
161178
/// [Purple Mountain Observatory for the years 1900-2025]: http://www.pmo.cas.cn/xwdt2019/kpdt2019/202203/P020250414456381274062.pdf
162179
/// [Hong Kong Observatory for the years 1901-2100]: https://www.hko.gov.hk/en/gts/time/conversion.htm
163180
/// [GB/T 33661-2017]: China::gb_t_33661_2017
@@ -277,6 +294,12 @@ impl Rules for China {
277294

278295
/// The [`Rules`] used in [Korea](https://en.wikipedia.org/wiki/Korean_calendar).
279296
///
297+
/// # Precise definition and limits
298+
///
299+
/// This calendar is intended to represent the traditional Korean lunar calendar as used
300+
/// officially in the Republic of Korea as of 2025. This takes a best-effort approach
301+
/// to match past and future dates as used in the region for the year 1900 onwards.
302+
///
280303
/// This type agrees with the official data published by the
281304
/// [Korea Astronomy and Space Science Institute for the years 1900-2050].
282305
///
@@ -295,11 +318,19 @@ impl Rules for China {
295318
/// their own [`Rules`] type using data such as from the excellent compilation
296319
/// by [Yuk Tung Liu].
297320
///
321+
/// The precise behavior of this calendar may change in the future if:
322+
/// - The ground truth in South Korea changes, either through published government sources or most almanacs
323+
/// - Future data is published that we wish to incorporate
324+
/// - We decide to tweak the simplified calculation
325+
/// - We decide to expand the range where we are handling past dates.
326+
///
298327
/// [Korea Astronomy and Space Science Institute for the years 1900-2050]: https://astro.kasi.re.kr/life/pageView/5
299328
/// [adapted GB/T 33661-2017]: Korea::adapted_gb_t_33661_2017
300329
/// [GB/T 33661-2017]: China::gb_t_33661_2017
301330
/// [Yuk Tung Liu]: https://ytliu0.github.io/ChineseCalendar/table.html
302331
///
332+
/// # Example
333+
///
303334
/// ```rust
304335
/// use icu::calendar::cal::LunarChinese;
305336
/// use icu::calendar::Date;

components/calendar/src/cal/coptic.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ use tinystr::tinystr;
3535
///
3636
/// This calendar supports 13 solar month codes (`"M01" - "M13"`), with `"M13"` being used for the short epagomenal month
3737
/// at the end of the year.
38+
///
39+
/// # Precise definition and limits
40+
///
41+
/// This calendar is defined algorithmically as a solar calendar that has 13 months, with a leap day in
42+
/// the 13th month every 4 years, as used by the Coptic orthodox church as of 2025. This calendar extends proleptically
43+
/// before the time of its introduction.
3844
#[derive(Copy, Clone, Debug, Hash, Default, Eq, PartialEq, PartialOrd, Ord)]
3945
#[allow(clippy::exhaustive_structs)] // this type is stable
4046
pub struct Coptic;

components/calendar/src/cal/ethiopian.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ pub enum EthiopianEraStyle {
5858
///
5959
/// This calendar supports 13 solar month codes (`"M01" - "M13"`), with `"M13"` being used for the short epagomenal month
6060
/// at the end of the year.
61+
///
62+
/// # Precise definition and limits
63+
///
64+
/// This calendar is defined algorithmically as a solar calendar that has 13 months,
65+
/// as used as a civil calendar in Ethiopia as of 2025. This calendar extends proleptically
66+
/// before the time of its introduction.
6167
// The bool specifies whether dates should be in the Amete Alem era scheme
6268
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
6369
pub struct Ethiopian(EthiopianEraStyle);

components/calendar/src/cal/gregorian.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ impl GregorianYears for CeBce {
102102
/// # Month codes
103103
///
104104
/// This calendar supports 12 solar month codes (`"M01" - "M12"`)
105+
///
106+
/// # Precise definition and limits
107+
///
108+
/// This calendar is defined algorithmically as a solar calendar that has 12 months, with a leap day in the
109+
/// 2nd month every 4 and 400 years (but not every 100 years). As of 2025 it is a widely used civil calendar
110+
/// in most countries, including the UN. The Gregorian calendar was adopted gradually starting in the 1500s,
111+
/// this calendar extends proleptically before that.
105112
#[derive(Copy, Clone, Debug, Default)]
106113
#[allow(clippy::exhaustive_structs)] // this type is stable
107114
pub struct Gregorian;

components/calendar/src/cal/hebrew.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ use calendrical_calculations::rata_die::RataDie;
4040
/// [`MonthInfo`] has slightly divergent behavior: because the regular month Adar is formatted
4141
/// as "Adar II" in a leap year, this calendar will produce the special code `"M06L"` in any [`MonthInfo`]
4242
/// objects it creates.
43+
///
44+
/// # Precise definition and limits
45+
///
46+
/// This calendar is defined algorithmically as a lunar calendar with a leap 6th month every
47+
/// 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years, as used as an ecclesiastical calendar in Judaism
48+
/// as of 2025 (using the "civil new year" variant where Tishrei is the first month of the year).
49+
/// The precise algorithm used has [changed over time], with the modern one being in place
50+
/// since about 776 CE. This calendar extends that algorithm proleptically before that.
51+
///
52+
/// [changed over time]: https://hakirah.org/vol20AjdlerAppendices.pdf
4353
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord, Default)]
4454
#[allow(clippy::exhaustive_structs)] // unit struct
4555
pub struct Hebrew;

components/calendar/src/cal/hijri.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ mod ummalqura_data;
4949
///
5050
/// This calendar is a pure lunar calendar with no leap months. It uses month codes
5151
/// `"M01" - "M12"`.
52+
///
53+
/// # Precise definition and limits
54+
///
55+
/// This calendar generically covers any pure lunar calendar used ecclesiastically in Islam,
56+
/// with 12 months each of length 29 or 30, with an epoch intended to mark the Hijrah in 622 CE.
57+
///
58+
/// In practice, this calendar can be backed by a precise algorithm, an algorithm with official tables,
59+
/// astronomical simulation, or pure observation.
60+
///
61+
/// Further details can be found on individual calendar types.
5262
#[derive(Clone, Debug, Default, Copy)]
5363
#[allow(clippy::exhaustive_structs)] // newtype
5464
pub struct Hijri<S>(pub S);
@@ -112,6 +122,14 @@ pub trait Rules: Clone + Debug + crate::cal::scaffold::UnstableSealed {
112122
///
113123
/// This corresponds to the `"islamic-rgsa"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier)
114124
/// if constructed with [`Hijri::new_simulated_mecca()`].
125+
///
126+
/// # Precise definition and limits
127+
///
128+
/// This calendar simulates the lunar cycle for a given location. This currently
129+
/// simulates the calendar for all time using the same calculations, but we may
130+
/// in the future introduce approximations for non-modern dates.
131+
///
132+
/// The precise behavior of this calendar for any and all dates may change in the future.
115133
#[derive(Copy, Clone, Debug)]
116134
pub struct AstronomicalSimulation {
117135
pub(crate) location: SimulatedLocation,
@@ -239,6 +257,20 @@ impl Rules for AstronomicalSimulation {
239257
/// calendar authority.
240258
///
241259
/// This corresponds to the `"islamic-umalqura"` [CLDR calendar](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier).
260+
///
261+
/// # Precise definition and limits
262+
///
263+
/// This calendar is intended to match the Umm al-Qura calendar defined and published by the Kingdom of Saudi Arabia,
264+
/// with the source of truth being government published data/almanacs.
265+
///
266+
/// Outside the range 1300 AH (1882-11-12 ISO) to the end of 1600 AH (2174-11-25 ISO) it falls back
267+
/// to a tabular approximation. These ranges may change in the future.
268+
///
269+
/// The precise behavior of this calendar may change in the future if:
270+
/// - The ground truth in Saudi Arabia changes, either through published government sources or most almanacs
271+
/// - Future data is published that we wish to incorporate
272+
/// - We decide to tweak the simplified calculation
273+
/// - We decide to expand the range where we are handling past dates.
242274
#[derive(Copy, Clone, Debug, Default)]
243275
#[non_exhaustive]
244276
pub struct UmmAlQura;
@@ -315,6 +347,11 @@ impl Rules for UmmAlQura {
315347
///
316348
/// When constructed with [`TabularAlgorithmLeapYears::TypeII`], and either [`TabularAlgorithmEpoch::Friday`] or [`TabularAlgorithmEpoch::Thursday`],
317349
/// this corresponds to the `"islamic-civil"` and `"islamic-tbla"` [CLDR calendars](https://unicode.org/reports/tr35/#UnicodeCalendarIdentifier) respectively.
350+
///
351+
/// # Precise definition and limits
352+
///
353+
/// This calendar is defined algorithmically based on the algorithm selected by the choice of [`TabularAlgorithmLeapYears`],
354+
/// and the epoch selected by the choice of [`TabularAlgorithmEpoch`].
318355
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
319356
pub struct TabularAlgorithm {
320357
pub(crate) leap_years: TabularAlgorithmLeapYears,

components/calendar/src/cal/indian.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ use tinystr::tinystr;
2828
/// # Month codes
2929
///
3030
/// This calendar supports 12 solar month codes (`"M01" - "M12"`)
31+
///
32+
/// # Precise definition and limits
33+
///
34+
/// This calendar is defined algorithmically as a solar calendar that has 12 months, as used alongside the
35+
/// Gregorian calendar by the Government of India by the name "Śaka calendar" as of 2025.`
36+
///
37+
/// The Śaka calendar was introduced in 1957, but this calendar extends proleptically before that.
3138
#[derive(Copy, Clone, Debug, Hash, Default, Eq, PartialEq, PartialOrd, Ord)]
3239
#[allow(clippy::exhaustive_structs)] // this type is stable
3340
pub struct Indian;

components/calendar/src/cal/iso.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ use tinystr::tinystr;
2121
/// # Month codes
2222
///
2323
/// This calendar supports 12 solar month codes (`"M01" - "M12"`)
24+
///
25+
/// # Precise definition and limits
26+
///
27+
/// This calendar is defined algorithmically as a solar calendar that is identical to the proleptic Gregorian calendar
28+
/// in everything except the way eras are handled.
2429
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2530
#[allow(clippy::exhaustive_structs)] // this type is stable
2631
pub struct Iso;

components/calendar/src/cal/japanese.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ use tinystr::tinystr;
3939
/// # Month codes
4040
///
4141
/// This calendar supports 12 solar month codes (`M01` - `M12`)
42+
///
43+
/// # Precise definition and limits
44+
///
45+
/// This calendar is defined algorithmically as a solar calendar that is identical to the proleptic Gregorian calendar in everything
46+
/// except year numbering. This happens to be the civil calendar used in Japan from 1873, this calendar extends proleptically
47+
/// before that.
4248
#[derive(Clone, Debug, Default)]
4349
pub struct Japanese {
4450
eras: DataPayload<CalendarJapaneseModernV1>,

0 commit comments

Comments
 (0)