Skip to content

Instantly share code, notes, and snippets.

@tadd
Last active August 20, 2022 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadd/cb4276e57fbf21fa4dd3bba453c4285e to your computer and use it in GitHub Desktop.
Save tadd/cb4276e57fbf21fa4dd3bba453c4285e to your computer and use it in GitHub Desktop.
大化の改新が二回起こる件について(蘇我入鹿は二度死ぬ)
const [lsyear, lslong] = [{year: 'numeric'}, {dateStyle: 'long'}].map(o =>
d => d && d.toLocaleString("ja-JP-u-ca-japanese", o));
const isolong = d => d && d.toISOString().slice(0, "yyyy-mm-dd".length);
const d = new Date(643, 0, 1);
let prevy, prevd;
for (let i = 0; i < 1300; i++) {
//console.debug(lslong(d));
const y = lsyear(d);
if (y !== prevy) {
const l = [prevd, d].map(d => `${lslong(d)} (${isolong(d)})`);
console.log(l.join(' -> '));
prevy = y;
}
prevd = new Date(d); // clone
d.setDate(d.getDate() + 1);
}
# node -v #=> v18.7.0
undefined (undefined) -> 大化-2年12月29日 (0642-12-31)
大化-2年12月31日 (0643-01-02) -> 大化元年1月1日 (0643-01-03)
大化元年12月31日 (0644-01-02) -> 大化0年1月1日 (0644-01-03)
大化0年12月31日 (0645-01-02) -> 大化元年1月1日 (0645-01-03)
大化元年12月31日 (0646-01-02) -> 大化2年1月1日 (0646-01-03)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment