eraYearsOffunction
Every era year that falls in a Western year, the newest era first.
Most years have one answer. The years an era changed in have two: 1912 is 大正1 and 明治45, 1926 is 昭和1 and 大正15, 1989 is 平成1 and 昭和64, 2019 is 令和1 and 平成31. 1868 is 明治1 alone.
Import it
import { eraYearsOf } from "@johnmorrisdotca/hikidashi/wareki";
Also exported from: @johnmorrisdotca/hikidashi
Definition
function eraYearsOf(westernYear: number): EraYear[]
Parameters
| Name | Type | Description |
|---|---|---|
westernYear | number | A Western year, such as 1989. |
Returns
EraYear[]
One era year, or two in a year an era changed in, newest first; an empty list for a year before 1868, a year past the reach of the era still running, or a number that is not a whole year.
Examples
import { eraYearsOf } from "@johnmorrisdotca/hikidashi/wareki";
console.log(eraYearsOf(1989).map((one) => `${one.era.kanji}${one.year}`));
console.log(eraYearsOf(2000).map((one) => `${one.era.kanji}${one.year}`), eraYearsOf(1850));[ '平成1', '昭和64' ]
[ '平成12' ] []What it prints (run when this page was built)