1.1.0 • Published 1 year ago

wareki-tool-kit v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

wareki-tool-kit

npm version License: MIT

A collection of tools to manipulate the Japanese and Western calendars for javascript and typescript.

Link

日本語の説明書👉JP-README.md

For development👉DEVELOP.md

Installation

npm install wareki-tool-kit
yarn add wareki-tool-kit

Usage

javascript and typescript are supported.

import {toJapaneseCalendar, toGregorian} from 'wareki-tool-kit'

// ⏬toJapaneseCalendar
toJapaneseCalendar('2019年03月23日') // 令和元年3月23日
toJapaneseCalendar('2019/03/23') // 令和元年3月23日
toJapaneseCalendar('2019-03-23') // 令和元年3月23日
// option1(Whether to use numerals or kanji for the original number. Default is false.)
toJapaneseCalendar('2019-03-23', true) // 令和1年3月23日
toJapaneseCalendar('2019-03-23', false) // 令和元年3月23日
// option2(zero-fill. Default is false.)
toJapaneseCalendar('2019-03-03', false, true) // 令和元年03月03日
toJapaneseCalendar('2019-03-03', false, false) // 令和元年3月3日


// ⏬toGregorian
toGregorian('令和2年5月10日') // 2020年5月10日
toGregorian('令和1年5月10日') // 2019年5月10日
toGregorian('令和元年5月10日') // 2019年5月10日
// option(Separator select. Default is 'k'.)
toGregorian('令和2年5月10日', '/')// 2020/5/10
toGregorian('令和2年5月10日', '-')// 2020-5-10
toGregorian('令和2年5月10日', 'k')// 2020年5月10日
// option2(zero-fill. Default is false.)
toGregorian('令和2年5月9日', 'k', true)// 2020年05月09日
toGregorian('令和2年5月9日', 'k', false)// 2020年5月9日
toGregorian('令和2年5月9日', '/', true)// 2020/05/09
toGregorian('令和2年5月9日', '/', false)// 2020/5/9

Supported Japanese calendar

Japanese CalendarAD
令和2019
平成1989
昭和1926
大正1912
明治1868
慶応1865
元治1864
文久1861
万延1860
安政1854
嘉永1848
弘化1844
天保1830
文政1818
文化1804
享和1801
寛政1789
天明1781
安永1772
明和1764
宝暦1751
寛延1748
延享1744
寛保1741
元文1736
享保1716
正徳1711
宝永1704
元禄1688
貞享1684
天和1681
延宝1673
寛文1661
万治1658
明暦1655
承応1652
慶安1648
正保1644
寛永1624
元和1615

License

MIT