// This file is part of ICU4X. // // The contents of this file implement algorithms from Calendrical Calculations // by Reingold & Dershowitz, Cambridge University Press, 4th edition (2018), // which have been released as Lisp code at <https://github.com/EdReingold/calendar-code2/> // under the Apache-2.0 license. Accordingly, this file is released under // the Apache License, Version 2.0 which can be found at the calendrical_calculations // package root or at http://www.apache.org/licenses/LICENSE-2.0.
// 1st Jan of 1st year proleptic Julian is equivalent to December 30th of 0th year proleptic Gregorian const JULIAN_EPOCH: RataDie = crate::gregorian::fixed_from_gregorian(0, 12, 30);
/// Get a fixed date from the ymd of a Julian date. /// /// Years are counted as in _Calendrical Calculations_ by Reingold & Dershowitz, /// meaning there is no year 0. For instance, near the epoch date, years are counted: -3, -2, -1, 1, 2, 3 instead of -2, -1, 0, 1, 2, 3. /// /// Primarily useful for use with code constructing epochs specified in the bookg pubconstfn fixed_from_julian_book_version(book_year: i32, month: u8, day: u8) -> RataDie {
debug_assert!(book_year != 0); // TODO: Should we check the bounds here?
fixed_from_julian( if book_year < 0 {
book_year + 1
} else {
book_year
},
month,
day,
)
}
/// Calculates the date of Easter in the given year pubfn easter(year: i32) -> RataDie { let shifted_epact = (14 + 11 * year.rem_euclid(19)) % 30; let paschal_moon = fixed_from_julian(year, 4, 19) - shifted_epact as i64;
k_day_after(0, paschal_moon)
}
#[test] fn test_easter() { // https://en.wikipedia.org/wiki/List_of_dates_for_Easter, dates in Gregorian for (y, m, d) in [
(2021, 5, 2),
(2022, 4, 24),
(2023, 4, 16),
(2024, 5, 5),
(2025, 4, 20),
(2026, 4, 12),
(2027, 5, 2),
(2028, 4, 16),
(2029, 4, 8),
] {
assert_eq!(easter(y), crate::gregorian::fixed_from_gregorian(y, m, d));
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-08-24)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.