GithubHelp home page GithubHelp logo

mjkhonline / shamsi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from msdit/shamsi

0.0 0.0 0.0 19 KB

A Jalali to Gregorian converter with no dependency in javascript

License: MIT License

JavaScript 100.00%

shamsi's Introduction

Shamsi

A Jalali to Gregorian and Gregorian to Jalali converter with no dependency!

MIT License NPM version Codacy Badge

How to

This plugin convert jalali to gregorian and gregorian to jalali in the most simple way

Convert gregorian to jalali

shamsi.gregorianToJalali(1989, 1, 24); //[1367, 11, 4]

Convert jalali to gregorian

shamsi.jalaliToGregorian(1367, 11, 4); //[1989, 1, 24]

Install

Install via npm

npm install shamsi -S

Install via yarn

yarn add shamsi

Using in Node.js

Install it via npm or yarn then use it as the following code

var shamsi = require("shamsi");
shamsi.gregorianToJalali(1989, 1, 24);

Using in browser

ES5

get library using bower, npm, cdn, or cloning the repository

<script src="https://unpkg.com/shamsi"></script>

<script>
  shamsi.gregorianToJalali(1989, 1, 24);
</script>

React

import * as shamsi from 'shamsi';
...
render() {
  return (<p>{shamsi.gregorianToJalali(1989, 1, 24).join('/')}</p>);
}

Jquery

get library using bower, npm, cdn, or cloning the repository

<script src="https://unpkg.com/shamsi"></script>

<script>
  $("#date").text(shamsi.gregorianToJalali(1989, 1, 24).join('/'));
</script>

Using Date

If you want to pass date as input like:

var date1 = new Date("December 17, 1995 03:24:00");
// OR
var date2 = new Date("1995-12-17T03:24:00");
// OR sth else

gregorianToJalali(date1);

you have to use shamsi-date-converter

Format date

If you want to pass formatted date as input or get formatted date from output like:

gregorianToJalali("1995/7/17"); // => 1374/4/26
// OR
jalaliToGregorian("1374/4/26"); // => 1995/7/17
// OR other formats as input or outputs

you have to use shamsi-formatter

shamsi's People

Contributors

msdit avatar

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.