shamsi
TypeScript icon, indicating that this package has built-in type declarations

1.1.6 • Public • Published

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

shamsi-date-converter

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

shamsi-formatter

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.62,724latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.62,724
1.1.50
1.1.40
1.1.30
1.1.20
1.1.10
1.0.10
1.0.00
0.1.10
0.1.00

Package Sidebar

Install

npm i shamsi

Weekly Downloads

2,724

Version

1.1.6

License

MIT

Unpacked Size

6.84 kB

Total Files

5

Last publish

Collaborators

  • maghaie148