Skip to content

Arithmetic year for "chinese" and "dangi" calendars is different from the spec #439

@fabon-f

Description

@fabon-f
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
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-internalInternal library improvementsblockedWaiting for some code change

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions