moment-jalaali
A Jalaali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js.
About
Jalali calendar is a solar calendar that was used in Persia, variants of which today are still in use in Iran as well as Afghanistan. Read more on Wikipedia or see Calendar Converter.
This plugin adds Jalaali calendar support to momentjs library.
Calendar conversion is based on the algorithm provided by Kazimierz M. Borkowski and has a very good performance.
Where to use it
Like momentjs
, moment-jalaali
works in browser and in Node.js.
Node.js
npm install moment-jalaali
var moment =
Browser
It is recommended to use component
. Otherwise, you may use the build/moment-jalaali.js
file.
<script src="moment.js"></script>
<script src="moment-jalaali.js"></script>
<script>
moment().format('jYYYY/jM/jD')
</script>
API
This plugin tries to mimic momentjs
api. Basically, when you want to format or parse a string, just add a j
to the format token like 'jYYYY' or 'jM'. For example:
m = // Parse a Jalaali datem // 1360/5/26 is 1981/8/17 m // 1360m // 4m // 26m // 150m // 22m // 1360 mmmm // 1361/7/29 mmm // 1361/12/1 mmm // 1392/1/1 mmm // 1390/12/1 // true (leap year) // false (common year)moment // truemoment // false // 2013-8-25 16:40:00 // 1392/6/31 23:59:59 // Complex parse: // 1981/07/17
To add Persian language, use loadPersian method:
moment
moment-hijri
Another calendar system plugin for momentjs
is moment-hijri
created by @xsoh.
License
MIT