リファレンス
和暦
import { … } from "@johnmorrisdotca/hikidashi/wareki";
最小化と gzip 圧縮をしたサイズは 1.3 kB(読み込むものをすべて含み、esbuild で計測)
リファレンスの説明と例は英語です。見出しと目次は日本語です。
和暦: Japanese era years, and the Western years and dates they name, both ways.
Working out what 平成3年 is means knowing where the era started and subtracting one, which is
exactly the arithmetic nobody wants to do in their head while reading a form, a coin or somebody's
birth year. This goes from an era year to a Western year (parseEraYear), from a Western year or a
date to the era year it falls in (eraYearOf, eraYearsOf, eraOnDate), and writes the answer
(formatEraYearJapanese).
Five eras, back to 明治. Not because the earlier ones do not exist, since there are two hundred and more, but because 1868 is where the modern calendar begins, and a date before it is a history question rather than a reading one. Every date here is in the Gregorian calendar.
An era changes partway through a Western year, so a year can belong to two of them: 1989 is 昭和64
until 7 January and 平成1 from the 8th. eraYearsOf answers with both; eraOnDate says which one a
day is in.
エクスポート
| 名前 | 種類 | 概要 |
|---|---|---|
eraOnDate | 関数 | The era year a day is in, from YYYY-MM-DD or a Date. |
EraYear | 型 | An era year that parsed or was found, and the Western year it names: what parseEraYear, eraYearOf, eraYearsOf and eraOnDate give. |
eraYearOf | 関数 | The era year a Western year is usually written as: the newest era's, so 1989 is 平成1 and 2019 is 令和1. |
eraYearsOf | 関数 | Every era year that falls in a Western year, the newest era first. |
formatEraYearJapanese | 関数 | The era year as it is written in Japanese: 平成3年. |
formatEraYearRomaji | 関数 | The era year as it is written in Latin letters: Heisei 3. |
JAPANESE_ERAS | 定数 | The five modern eras, oldest first: 明治, 大正, 昭和, 平成 and 令和. |
JapaneseEra | 型 | An era, as it is written, said and counted: one row of JAPANESE_ERAS. |
parseEraYear | 関数 | The era year a text names, or null when it does not name one. |
westernYearFor | 関数 | The Western year an era year falls in, or null when the era never had that year. |
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。