jc

jdate-convert

A javascript library for converting solar(jalali) date to gregorian date and vice versa.

Showing:

Popularity

Downloads/wk

6

GitHub Stars

6

Maintenance

Last Commit

3mos ago

Contributors

0

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

JDate-Convert

A Javascript library for converting Solar (Jalali) date to Gregorian and Gregorian date to Solar(Jalali) date with support of date formats.

Installation

Install via NPM/Yarn:

npm install jdate-convert

Usage

  • The first parameter is required to be a date string in the one of the following formats yyyy-MM-dd, yyyy/MM/dd
  • Second parameter is optional for formating the output.
const {toGregorian, toSolar} = require('jdate-convert')


const a = toGregorian('1400-04-24')                  //  2021-07-15
const b = toGregorian('1400-04-24', 'yyyy/MM/dd')    //  2021/07/15
const c = toGregorian('1400/04/24', 'yyyy/MMM/dd')   //  2021/Jul/15
const d = toGregorian('1400-04-24', 'yyyy/MMMM/dd')  //  2021/July/15

const a = toSolar('2021-06-14')                      //  1400-03-24
const b = toSolar('2021-06-14', 'yyyy/MM/dd')        //  1400/03/24
const c = toSolar('2021/06/14', 'yyyy-MMM-dd')       //  1400-ا      24-جوزا

toSolar function also accepts a third optional boolean paramater while using date formats to return month name in Dari or Irani (Default Dari).

const result = toSolar('2021-06-14', 'yyyy-MMM-dd', false)   // output 1400-ا      24-خرداد 

Supported formats

FormattoGregoriantoSolar
yyyy-MM-ddYesYes
yyyy-MMM-ddYesYes
yyyy-MMMM-ddYesNo

Supported separators are -, / and whitespace.

Contribute

Report bugs and suggest feature in issue tracker. Feel free to Fork and send Pull Requests.

License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100