📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

dayjs-jp-era

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dayjs-jp-era

Japanese Era format for dayjs.

1.0.7
latest
Source
npm
Version published
Weekly downloads
41
241.67%
Maintainers
1
Weekly downloads
 
Created
Source

dayjs-jp-era

目的

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

Usage

  • 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
  • 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令和日付に応じた元号

FAQs

Package last updated on 28 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts