Skip to content

Commit

Permalink
Move test for dates before start of the Japanese era into a new file
Browse files Browse the repository at this point in the history
See also <tc39/proposal-temporal#2865>
requesting for more information how this case should actually be
handled.
  • Loading branch information
anba authored and ptomato committed Jul 25, 2024
1 parent dcaed05 commit f68a7a7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 55 deletions.
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);
55 changes: 0 additions & 55 deletions test/staging/Intl402/Temporal/old/japanese-era.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f68a7a7

Please sign in to comment.