Giter VIP home page Giter VIP logo

japanese-date-converter's Introduction

japanese-date-converter

npm version main

This module help you to convert Japanese date and Western years.

Demo Page

Installation

Using in CommonJS

In CommonJS, please use like this.

const { JapaneseDateConverter } = require('japanese-date-converter')

const inputValue = "R01/05/01";
const settings = {
  format: "yyyy/MM/dd"
};
const converter = new JapaneseDateConverter({ inputValue, settings });
const convertedValue = converter.execute();
console.log(convertedValue); // "2019/05/01"

Using in ES Modules

In ES Modules, please use like this.

import { JapaneseDateConverter } from "japanese-date-converter";

const inputValue = "R01/05/01";
const settings = {
  format: "yyyy/MM/dd"
};
const converter = new JapaneseDateConverter({ inputValue, settings });
const convertedValue = converter.execute();
console.log(convertedValue); // "2019/05/01"

Using in jQuery

Download script in dist folder, and include the script after loading your jQuery library.

<script src="../dist/jquery.japanese-date-converter.js"></script>

And, call like this.
In this library, library catch change event, so inputted text will be formatted automatically after text entering.

<script>
  $(document).ready(function () {
    $("#target").japanese_date_converter({ format: "yyyy/MM/dd" });
  });
</script>

Details

  1. When text inputted, the text will be parsed internally in this library.

  2. After parsed internally in this library, parsed date(time) will be formatted as given format.

  • example
    • When format is "gee/MM/dd", "2019/04/30" will be formatted as "H31/04/30".
    • When format is "ggge年M月d日", "2019/04/05" will be formatted as "平成31年4月5日".
  • If you'd like to know more, please check Demo Page.
  1. Supported format is as below.
years
style example date converted example
ggg 2019/04/30 平成
gg 2019/04/30
g 2019/04/30 H
yyyy 2019/04/30 2019
yy 2019/04/30 19
ee 1990/04/30 02
e 1990/04/30 2
months
style example date converted example
mmmmm 2019/04/30 A
mmmm 2019/04/30 April
mmm 2019/04/30 Apr
MM 2019/04/30 04
M 2019/04/30 4
days
style example date converted example
dd 2019/04/02 02
d 2019/04/02 2

Contributing

  1. fork this repository.
  2. run yarn install
  3. fix or add new feature.
  4. after fix or add new feature, run these command.
  • yarn lint
  • yarn test
  • yarn build
  1. if any warn or error occurred, fix your code and run above commands again.
  2. commit your changes, and create Pull Request in GitHub.

Authors

shoutatani

japanese-date-converter's People

Contributors

dependabot[bot] avatar shoutatani avatar

Stargazers

 avatar  avatar

Forkers

ghiteze

japanese-date-converter's Issues

Year ranges are not validated

For each era, the years passed should only accept the valid range for that era. E.g. for Meiji 1-80 or showa 1-64.

E.g. this should throw an error that 81 is not a valid year for the Meiji era:

new JapaneseDateConverter({
   inputValue: `1810701`,
   settings: {
     format: 'yyyy-mm-dd',
   },
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.