Skip to content

TypeScript 向け🇯🇵和暦 <=> 📅西暦変換。西暦 645 年(大化元年)以降全元号対応。

Notifications You must be signed in to change notification settings

Cygra/date-format-wareki

Repository files navigation

date-format-wareki

和暦 <=> 西暦変換

全元号対応:西暦 645 年(大化元年)以降

南北朝時代:{ nanboku: "south" | "north" }

インストール

npm install date-format-wareki

使い方

西暦 => 和暦

import { toWareki, toDate } from "date-format-wareki";

const date = new Date(1996, 10, 27);
toWareki(date); // => "平成8/11/27"
toWareki(date, { era: "narrow" }); // => "H8/11/27"

const date = new Date(1338, 10, 27);
toWareki(date, { nanboku: "south" }); // => "延元3/11/27"
toWareki(date, { nanboku: "north" }); // => "暦応1/11/27"

和暦 => 西暦

toDate("平成8/11/27"); // => new Date(1996, 10, 27)
toDate("延元3/11/27", { namboku: "south" }); // => new Date(1338, 10, 27)

About

TypeScript 向け🇯🇵和暦 <=> 📅西暦変換。西暦 645 年(大化元年)以降全元号対応。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published