parseEraYear関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
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 { parseEraYear } from "@johnmorrisdotca/hikidashi/wareki";
ほかのエクスポート元: @johnmorrisdotca/hikidashi
定義
function parseEraYear(raw: string): EraYear | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
raw | string | What somebody typed: 令和6年, 平成3年, 昭和元年, "Heisei 3", "Shōwa 64". |
戻り値
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.
例
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出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。