Socket
Book a DemoInstallSign in
Socket

wareki2era

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wareki2era

convert japanese Wareki(和暦) to Era(西暦)

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

wareki2era.js

convert Japanese Wareki(日本の元号 | 和暦) to the Era(西暦) for javascript

wareki2era.js is tiny javascript library. which is able to convert Japanese Wareki(和暦|元号) to Era (西暦).

Installation

# npm
npm i wareki2era
# yarn
yarn add wareki2era

Or you can import directly via CDN.

<script src="https://unpkg.com/wareki2era/dist/wareki2era.browser.js"></script>

Basic Usage

wareki2era( JapaneseEraDate ) : String

japaneseEraDate shoud be (明治|大正|昭和|平成|令和)YYYY年MM月DD日

CommonJS (node.js) || ES6 or later (babel)

const wareki2era = require("wareki2era");
// import wareki2era from "wareki2era";

let jpnEra = "明治四五年一二月十日";

wareki2era(jpnEra); // 1912-12-10

Web browser

<script>
var jpnEra = '昭和八年九月九日';

console.log(wareki2era(jpnEra)); // 1933-09-09

</script>

With options

With second argument, you can assgin splited character whatever you want.

var jpnEra = "明治四五年一二月十日";

// default
wareki2era(jpnEra); // 1912-12-10

// with option
wareki2era(jpnEra, "/"); // 1912/12/10
wareki2era(jpnEra, "#"); // 1912#12#10

In addition j option is return japanese date of string.

// with 'j' option
wareki2era(jpnEra, "j"); // 1912年12月10日

Changelog

  • version 1.0.0 : Adapted '令和'

Credit

Special thanks to http://sm.2-d.jp's liblary. wareki2era.js is using it while converting kan-suji(漢数字) to Arabic number.

Licence

MIT

Keywords

japanese

FAQs

Package last updated on 01 Apr 2019

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.