Open anba opened 6 months ago
Still reproduces with release 1.5, except that the assertions are changed:
Chinese/Dangi:
calendrical_calculations-0.1.1/src/chinese_based.rs:571:9:
assertion failed: diff == 29 || diff == 30
IslamicObservational:
calendrical_calculations-0.1.1/src/islamic.rs:92:21:
(ObservationalIslamic) Found year -280804 AH with month length 26 for month 1!
IslamicUmmAlQura:
calendrical_calculations-0.1.1/src/islamic.rs:59:17:
(SaudiIslamic) Found year -280804 AH with length 319!
Yeah, I managed to get these to work for much larger ranges (thousands of years) in #4904, but dates that far away (hundreds of thousands of years) still have precision issues.
A few potential paths forward:
@Manishearth @roozbehp
Can we have these assertions not fail outside of ranges where we expect the calendar to be well-behaved?
Start time: 11:05
Options:
Proposal: Option 3 or 3a with data size bikeshed tbd after implementation. Temporal issues to be filed upstream motivated by option 4. Ask for Temporal to not be handwavy about this.
Signoff: @sffc @manishearth @nekevss @echeran (@hsivonen?) (@robertbastian?)
Manish to file Temporal issue.
Related to option 3a: might be worth investigating whether Observational and Saudi islamic could share the data cache. Maybe not, because we're already extremely efficient, with 2 bytes per year per calendar.
I think that's unlikely but it's possible that there's an efficient way to represent their overlap.
Thanks @Manishearth for filing https://github.com/tc39/proposal-temporal/issues/2869
I found the Temporal invariants that lead to my position that we should enforce certain arithmetic behaviors in calendars we export. See my comment in the above issue.
@hsivonen - What does ICU4C do? @Manishearth - ICU4C doesn't have these assertions. I imagine it might fail the tests.
Evidence that ICU4C has similar problems but just doesn't have code assertions:
The assertion Year offset too big to store can also be triggered when using years too far into the future or past:
let cal = Chinese::new_always_calculating();
let era = Era::from_str("chinese").unwrap();
let month_code = MonthCode::from_str("M01").unwrap();
let date = cal.date_from_codes(era, 21206, month_code, 1).unwrap();
There are assertion failures when testing the minimum and maximum allowed
Temporal.PlainDate
values for the Chinese, Dangi, IslamicObservational, and IslamicUmmAlQura calendars.I don't know if #4904 will fix these issues, too.
(Tested with release 1.4.)