Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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

About

convert japanese Wareki(和暦) to Era(西暦) of date for javascript

Resources

License

Releases

No releases published

Packages

No packages published