mirror of
https://git.pumpin.online/funkpower/typikon.git
synced 2026-10-22 18:57:13 +00:00
the year 50 is the year 50, not 1950
new Date(50, 0, 1) is 1950: the Date constructor reads a year of 0..99 as 1900 + n, and the setter does not. This calendar answers from the year 1, so pascha() for an early year had been quietly reporting a twentieth-century date.
This commit is contained in:
@@ -129,6 +129,14 @@ check("pascha matches the published dates", () => {
|
||||
assert.equal(iso(typikon.pascha(2027, "old")), "2027-05-02");
|
||||
});
|
||||
|
||||
check("a two-digit year is that year, not 19xx", () => {
|
||||
// The Date constructor reads 0..99 as 1900 + n, which would have made the
|
||||
// Paschalion for the year 50 answer for 1950 without a word.
|
||||
assert.equal(typikon.pascha(50, "old").getFullYear(), 50);
|
||||
assert.equal(typikon.pascha(99, "old").getFullYear(), 99);
|
||||
assert.equal(typikon.pascha(100, "old").getFullYear(), 100);
|
||||
});
|
||||
|
||||
check("every listed jurisdiction reckons", () => {
|
||||
const all = typikon.jurisdictions();
|
||||
assert.ok(all.length > 20);
|
||||
|
||||
+8
-1
@@ -164,7 +164,14 @@ fn from_js_date(d: &js_sys::Date) -> Result<Date, JsError> {
|
||||
|
||||
fn to_js_date(d: Date) -> js_sys::Date {
|
||||
let (y, m, day) = d.ymd();
|
||||
js_sys::Date::new_with_year_month_day(y as u32, m as i32 - 1, day as i32)
|
||||
let out = js_sys::Date::new_with_year_month_day(y as u32, m as i32 - 1, day as i32);
|
||||
// `new Date(50, 0, 1)` is 1950, not the year 50: the two-digit-year rule is
|
||||
// in the constructor and not in the setter. This calendar answers from the
|
||||
// year 1, so the rule has to be undone rather than lived with.
|
||||
if (0..=99).contains(&y) {
|
||||
out.set_full_year(y as u32);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
// ──────────────────────────────── the api ─────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user