Arithmetic year for "chinese" and "dangi" calendars is different from the spec
use temporal_rs::{PlainDate, Calendar};
use tinystr::tinystr;
use core::str::FromStr;
fn main() {
let iso8601_date = PlainDate::try_new_iso(2025, 7, 23).unwrap();
let chinese_date = iso8601_date.with_calendar(Calendar::from_str("chinese").unwrap()).unwrap();
let korean_date = iso8601_date.with_calendar(Calendar::from_str("dangi").unwrap()).unwrap();
println!("{} {}", chinese_date.year(), korean_date.year());
}
Current output is 4662 4358, but it should be 2025 2025 according to the spec (https://tc39.es/proposal-intl-era-monthcode/#table-epoch-years), which means year should return related ISO year for these calendars.
// in Firefox Nightly
console.log(
Temporal.PlainDate.from("2025-01-01[u-ca=chinese]").year // 2024
Temporal.PlainDate.from("2025-07-23[u-ca=chinese]").year, // 2025
Temporal.PlainDate.from("2025-01-01[u-ca=dangi]").year // 2024
Temporal.PlainDate.from("2025-07-23[u-ca=dangi]").year, // 2025
);
Hmmm, interesting.
This appears to be related to SpiderMonkey using YearInfo's era_year_or_related_iso.
https://github.com/mozilla-firefox/firefox/blob/main/js/src/builtin/temporal/Calendar.cpp#L1560C29-L1560C71
@Manishearth I haven't really been able to dig into some of the calendar specifics as much as I'd like. Is there a preference for era_year_or_related_iso vs. extended_year for PlainDate::year? That sounds like something that I'd expect more on eraYear.
We're actively in the process of fixing this for everyone 😄
https://github.com/unicode-org/icu4x/pull/6762
Part of the problem is that "Temporal Year" was only recently defined.
Part of the problem is that "Temporal Year" was only recently defined.
Yeah, I'm pretty sure I remembered reading threads on it. Just couldn't recall the exact details.
That PR looks exactly like what's needed!