本文へ移動

Hikidashi引き出し

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

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

目次

リファレンス · 和暦

eraOnDate関数

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

The era year a day is in, from YYYY-MM-DD or a Date.

Exact where eraYearOf cannot be: 1989-01-07 is 昭和64 and 1989-01-08 is 平成1.

インポート

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

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

定義

function eraOnDate(date: string | Date): EraYear | null

引数

名前型説明
datestring | Date

A day as YYYY-MM-DD (full-width digits are read too), or a Date, read as the day it shows in its own time zone.

戻り値

EraYear | null

The era year the day falls in; null for a day that is not on the calendar (the 30th of February), a text that is not YYYY-MM-DD, an invalid Date, or a day before 明治 began on 1868-10-23.

例

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

console.log(eraOnDate("1989-01-07")?.era.kanji, eraOnDate("1989-01-08")?.era.kanji);
console.log(eraOnDate("2019-05-01")?.era.romaji, eraOnDate("2023-02-30"));
昭和 平成
Reiwa null

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

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

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