本文へ移動

Hikidashi引き出し

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

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

目次

リファレンス · 和暦

westernYearFor関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

The Western year an era year falls in, or null when the era never had that year.

Minus one, because an era's first year is year one rather than year zero: 平成1年 is 1989, the year the era began, not the year after it. 昭和65 is null, since 昭和 ended in its 64th year.

インポート

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

ほかのエクスポート元: @johnmorrisdotca/hikidashi

定義

function westernYearFor(era: JapaneseEra, year: number): number | null

引数

名前型説明
eraJapaneseEra

One of JAPANESE_ERAS.

yearnumber

The year within the era, counting from 1 (元年 is 1).

戻り値

number | null

The Western year, or null when year is not a whole number from 1 to the era's last year (99 for the era still running): null means the era never had that year, never "unknown".

例

import { JAPANESE_ERAS, westernYearFor } from "@johnmorrisdotca/hikidashi/wareki";

const showa = JAPANESE_ERAS.find((era) => era.kanji === "昭和")!;
console.log(westernYearFor(showa, 64), westernYearFor(showa, 65));
1989 null

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

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

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