eraYearOffunction
The era year a Western year is usually written as: the newest era's, so 1989 is 平成1 and 2019 is
令和1. Use eraYearsOf to get both of a changeover year, or eraOnDate when the day is known.
Import it
import { eraYearOf } from "@johnmorrisdotca/hikidashi/wareki";
Also exported from: @johnmorrisdotca/hikidashi
Definition
function eraYearOf(westernYear: number): EraYear | null
Parameters
| Name | Type | Description |
|---|---|---|
westernYear | number | A Western year, such as 2024. |
Returns
EraYear | null
The newest era year in that Western year; null where eraYearsOf has nothing (before 1868, past the
reach of the era still running, or not a whole year).
Examples
import { eraYearOf, formatEraYearJapanese } from "@johnmorrisdotca/hikidashi/wareki";
console.log(formatEraYearJapanese(eraYearOf(2024)!), formatEraYearJapanese(eraYearOf(1989)!));
console.log(eraYearOf(1700));令和6年 平成1年
nullWhat it prints (run when this page was built)