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
引数
| 名前 | 型 | 説明 |
|---|---|---|
era | JapaneseEra | One of |
year | number | 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出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。