Move test for dates before start of the Japanese era into a new file

See also <https://github.com/tc39/proposal-temporal/issues/2865>
requesting for more information how this case should actually be
handled.
This commit is contained in:
André Bargull 2024-05-30 10:36:14 +02:00 committed by Philip Chimento
parent dcaed0523c
commit a238ad6a1e
2 changed files with 63 additions and 55 deletions

View File

@ -0,0 +1,63 @@
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal-intl
description: Japanese eras
features: [Temporal]
---*/
// Dates in same year before Japanese era starts will resolve to previous era
var date = Temporal.PlainDate.from({
era: "reiwa",
eraYear: 1,
month: 1,
day: 1,
calendar: "japanese"
});
assert.sameValue(`${ date }`, "2019-01-01[u-ca=japanese]");
assert.sameValue(date.era, "heisei");
assert.sameValue(date.eraYear, 31);
date = Temporal.PlainDate.from({
era: "heisei",
eraYear: 1,
month: 1,
day: 1,
calendar: "japanese"
});
assert.sameValue(`${ date }`, "1989-01-01[u-ca=japanese]");
assert.sameValue(date.era, "showa");
assert.sameValue(date.eraYear, 64);
date = Temporal.PlainDate.from({
era: "showa",
eraYear: 1,
month: 1,
day: 1,
calendar: "japanese"
});
assert.sameValue(`${ date }`, "1926-01-01[u-ca=japanese]");
assert.sameValue(date.era, "taisho");
assert.sameValue(date.eraYear, 15);
date = Temporal.PlainDate.from({
era: "taisho",
eraYear: 1,
month: 1,
day: 1,
calendar: "japanese"
});
assert.sameValue(`${ date }`, "1912-01-01[u-ca=japanese]");
assert.sameValue(date.era, "meiji");
assert.sameValue(date.eraYear, 45);
date = Temporal.PlainDate.from({
era: "meiji",
eraYear: 1,
month: 1,
day: 1,
calendar: "japanese"
});
assert.sameValue(`${ date }`, "1868-01-01[u-ca=japanese]");
assert.sameValue(date.era, "ce");
assert.sameValue(date.eraYear, 1868);

View File

@ -58,61 +58,6 @@ var date = Temporal.PlainDate.from({
});
assert.sameValue(`${ date }`, "1869-01-01[u-ca=japanese]");
// Dates in same year before Japanese era starts will resolve to previous era
var date = Temporal.PlainDate.from({
era: "reiwa",
eraYear: 1,
month: 1,
day: 1,
calendar: "japanese"
});
assert.sameValue(`${ date }`, "2019-01-01[u-ca=japanese]");
assert.sameValue(date.era, "heisei");
assert.sameValue(date.eraYear, 31);
date = Temporal.PlainDate.from({
era: "heisei",
eraYear: 1,
month: 1,
day: 1,
calendar: "japanese"
});
assert.sameValue(`${ date }`, "1989-01-01[u-ca=japanese]");
assert.sameValue(date.era, "showa");
assert.sameValue(date.eraYear, 64);
date = Temporal.PlainDate.from({
era: "showa",
eraYear: 1,
month: 1,
day: 1,
calendar: "japanese"
});
assert.sameValue(`${ date }`, "1926-01-01[u-ca=japanese]");
assert.sameValue(date.era, "taisho");
assert.sameValue(date.eraYear, 15);
date = Temporal.PlainDate.from({
era: "taisho",
eraYear: 1,
month: 1,
day: 1,
calendar: "japanese"
});
assert.sameValue(`${ date }`, "1912-01-01[u-ca=japanese]");
assert.sameValue(date.era, "meiji");
assert.sameValue(date.eraYear, 45);
date = Temporal.PlainDate.from({
era: "meiji",
eraYear: 1,
month: 1,
day: 1,
calendar: "japanese"
});
assert.sameValue(`${ date }`, "1868-01-01[u-ca=japanese]");
assert.sameValue(date.era, "ce");
assert.sameValue(date.eraYear, 1868);
// Verify that CE and BCE eras (before Meiji) are recognized
date = Temporal.PlainDate.from({
era: "ce",