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

parseEraYearfunction

The era year a text names, or null when it does not name one.

元年, "first year", is spelled out rather than numbered on anything official, so it is read as the 1 it means. Everything else is a plain number, half-width or full, with or without the 年 that usually follows it. Latin names may be spelled with a long-vowel macron (Shōwa) or without.

Import it

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

Also exported from: @johnmorrisdotca/hikidashi

Definition

function parseEraYear(raw: string): EraYear | null

Parameters

NameTypeDescription
rawstring

What somebody typed: 令和6年, 平成3年, 昭和元年, "Heisei 3", "Shōwa 64".

Returns

EraYear | null

The era, the year within it and its Western year; null when the text does not name an era year, or names one the era never reached (昭和65年). Null is a refusal, never a guess.

Examples

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

console.log(parseEraYear("令和6年")?.westernYear);
console.log(parseEraYear("Heisei 3")?.westernYear, parseEraYear("昭和元年")?.westernYear);
console.log(parseEraYear("昭和65年"), parseEraYear("令和"));
2024
1991 1926
null null

What it prints (run when this page was built)

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