本文へ移動

Hikidashi引き出し

和暦と漢数字の相互変換、活用した語の辞書形、漢字への読みの割り当て、貼り付けた文からの単語の抽出、文の難しさ。日本語のテキストを扱う小さな道具を集めた引き出しです。

「引き出し」という名前は、道具が一つずつしまってあり、必要なときに取り出して使える、という意味です。 名前について(英語)

目次

リファレンス · 和暦

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

引数

名前型説明
rawstring

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/hikidashi 1.1.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。