Skip to the content

Hikidashi引き出し

Era dates (和暦) and kanji numerals both ways, the dictionary forms of a conjugated word, a reading shared out over its kanji, words pulled from pasted text, and how hard a sentence is to read.

Hikidashi (引き出し) is a drawer: each tool is pulled out when it is wanted. About the name

Contents

Reference · Era years

westernYearForfunction

The Western year an era year falls in, or null when the era never had that year.

Minus one, because an era's first year is year one rather than year zero: 平成1年 is 1989, the year the era began, not the year after it. 昭和65 is null, since 昭和 ended in its 64th year.

Import it

import { westernYearFor } from "@johnmorrisdotca/hikidashi/wareki";

Also exported from: @johnmorrisdotca/hikidashi

Definition

function westernYearFor(era: JapaneseEra, year: number): number | null

Parameters

NameTypeDescription
eraJapaneseEra

One of JAPANESE_ERAS.

yearnumber

The year within the era, counting from 1 (元年 is 1).

Returns

number | null

The Western year, or null when year is not a whole number from 1 to the era's last year (99 for the era still running): null means the era never had that year, never "unknown".

Examples

import { JAPANESE_ERAS, westernYearFor } from "@johnmorrisdotca/hikidashi/wareki";

const showa = JAPANESE_ERAS.find((era) => era.kanji === "昭和")!;
console.log(westernYearFor(showa, 64), westernYearFor(showa, 65));
1989 null

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hikidashi 1.1.0.