📅
和暦と西暦を変換するための NPM パッケージを作成しました
インストール
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)
Discussion