mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 03:01:12 +08:00
fix: PlainMonthDay/YearMonth toString 非 iso8601 日历补年份/日分量与日历注解
auto/缺省形(含 toJSON/toLocaleString 同形)对非 iso8601 日历恒输出裸
MM-DD / ±YYYY-MM:按 TemporalMonthDayToString/TemporalYearMonthToString,
showCalendar ∈ {always,critical} 或 calendar ≠ iso8601 时补参考年(PMD)/
参考日(PYM),注解按 FormatCalendarAnnotation(auto 仅非 iso 出 [u-ca=…]、
never 无注解、critical 前置 !)。ShowCalendar 拆分 auto/never(原 Omitted
合并两者致注解表不可表达),注解表独立成 helper 供两站点复用。
This commit is contained in:
@@ -2802,6 +2802,38 @@ fn plain_year_month_to_string_year_format() {
|
||||
assert_eq!(str_val(&vm, r), "-000001-08|-000001-08-01[u-ca=iso8601]|-000001-08");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plain_month_day_and_year_month_to_string_non_iso_calendar() {
|
||||
let mut vm = Vm::new();
|
||||
// 非 iso8601 日历:auto/缺省形补参考年(PMD,默认 1972)/参考日(PYM,默认 1)
|
||||
// 与 [u-ca=…] 注解;never 形仅分量无注解;toJSON/toLocaleString 走 auto 形。
|
||||
let r = eval(
|
||||
&mut vm,
|
||||
"(() => {
|
||||
const pmd = new Temporal.PlainMonthDay(5, 2, 'hebrew');
|
||||
const pym = new Temporal.PlainYearMonth(2021, 2, 'hebrew');
|
||||
return [
|
||||
pmd.toString(),
|
||||
pmd.toString({calendarName: 'never'}),
|
||||
pmd.toString({calendarName: 'always'}),
|
||||
pmd.toJSON(),
|
||||
pmd.toLocaleString(),
|
||||
pym.toString(),
|
||||
pym.toString({calendarName: 'never'}),
|
||||
pym.toJSON(),
|
||||
pym.toLocaleString(),
|
||||
].join('|');
|
||||
})()",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
str_val(&vm, r),
|
||||
"1972-05-02[u-ca=hebrew]|1972-05-02|1972-05-02[u-ca=hebrew]|1972-05-02[u-ca=hebrew]|\
|
||||
1972-05-02[u-ca=hebrew]|2021-02-01[u-ca=hebrew]|2021-02-01|2021-02-01[u-ca=hebrew]|\
|
||||
2021-02-01[u-ca=hebrew]"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plain_month_day_and_year_month_branding() {
|
||||
let mut vm = Vm::new();
|
||||
|
||||
Reference in New Issue
Block a user