eraOnDatefunction
The era year a day is in, from YYYY-MM-DD or a Date.
Exact where eraYearOf cannot be: 1989-01-07 is 昭和64 and 1989-01-08 is 平成1.
Import it
import { eraOnDate } from "@johnmorrisdotca/hikidashi/wareki";
Also exported from: @johnmorrisdotca/hikidashi
Definition
function eraOnDate(date: string | Date): EraYear | null
Parameters
| Name | Type | Description |
|---|---|---|
date | string | Date | A day as |
Returns
EraYear | null
The era year the day falls in; null for a day that is not on the calendar (the 30th of February), a text
that is not YYYY-MM-DD, an invalid Date, or a day before 明治 began on 1868-10-23.
Examples
import { eraOnDate } from "@johnmorrisdotca/hikidashi/wareki";
console.log(eraOnDate("1989-01-07")?.era.kanji, eraOnDate("1989-01-08")?.era.kanji);
console.log(eraOnDate("2019-05-01")?.era.romaji, eraOnDate("2023-02-30"));昭和 平成
Reiwa nullWhat it prints (run when this page was built)