Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust Temporal staging test of the Japanese calendar for alternative implementations #4102

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions test/staging/Intl402/Temporal/old/japanese-before-era.js
Original file line number Diff line number Diff line change
@@ -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);
66 changes: 9 additions & 57 deletions test/staging/Intl402/Temporal/old/japanese-era.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/*---
esid: sec-temporal-intl
description: Japanese eras
includes: [temporalHelpers.js]
features: [Temporal]
---*/

Expand Down Expand Up @@ -58,61 +59,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",
Expand All @@ -122,7 +68,10 @@ date = Temporal.PlainDate.from({
calendar: "japanese"
});
assert.sameValue(`${date}`, "1000-01-01[u-ca=japanese]");
assert.sameValue(date.era, "ce");
assert.sameValue(
TemporalHelpers.canonicalizeEraInCalendar(date, date.era),
TemporalHelpers.canonicalizeEraInCalendar(date, "ce"),
);
assert.sameValue(date.eraYear, 1000);

date = Temporal.PlainDate.from({
Expand All @@ -133,5 +82,8 @@ date = Temporal.PlainDate.from({
calendar: "japanese"
});
assert.sameValue(`${date}`, "0000-01-01[u-ca=japanese]");
assert.sameValue(date.era, "bce");
assert.sameValue(
TemporalHelpers.canonicalizeEraInCalendar(date, date.era),
TemporalHelpers.canonicalizeEraInCalendar(date, "bce"),
);
assert.sameValue(date.eraYear, 1);
Loading