Socket
Socket
Sign inDemoInstall

wareki2era

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    wareki2era

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


Version published
Maintainers
1
Install size
16.2 kB
Created

Readme

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

FAQs

Last updated on 01 Apr 2019

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc