1.0.7 • Published 1 year ago

dayjs-jp-era v1.0.7

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

dayjs-jp-era

目的

dayjsのformatにて日本の元号を表示するプラグインです。 https://github.com/hyakt/dayjs-jp-format さんをフォークしてます。 理由:平成30年のときに「平成30」、令和4年のとき「令和4年」と表記されてしまっていたため。

Usage

  1. Install the repository
npm install --save dayjs-jp-format
npm install --save dayjs # peer dependency

or

yarn add dayjs-jp-format
yarn add dayjs # peer dependency
  1. Import the jp format
import { jpFormat } from 'dayjs-jp-era'
dayjs.extend(jpFormat) // use plugin

const date = '2020-06-24'
const result = dayjs(date).format('rrrr')
console.log(result); //-> 令和2

const result = dayjs(date).format('rrrr年')
console.log(result); //-> 令和2年

const result = dayjs(date).format('rrr')
console.log(result); //-> 令和2年

const result = dayjs(date).format('rr')
console.log(result); //-> 令和

Format

FormatOutputDescription
rrrr令和2日付に応じた和暦(年は除く)
rrr令和2年年あり
rr令和日付に応じた元号
1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago