Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
moment-jalaali
Advanced tools
A Jalaali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js.
A Jalaali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js.
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.
Gzipped minified version is about 2kb.
Like momentjs
, moment-jalaali
works in browser and in Node.js.
npm install moment-jalaali
var moment = require('moment-jalaali');
moment().format('jYYYY/jM/jD');
<script src="moment.js"></script>
<script src="moment-jalaali.js"></script>
<script>
moment().format('jYYYY/jM/jD');
</script>
require.config({
paths: {
"moment": "path/to/moment",
"moment-jalaali": "path/to/moment-jalaali"
}
});
define(["moment-jalaali"], function (moment) {
moment().format('jYYYY/jM/jD');
});
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 = moment('1360/5/26', 'jYYYY/jM/jD'); // Parse a Jalaali date.
m.format('jYYYY/jM/jD [is] YYYY/M/D'); // 1360/5/26 is 1981/8/17
m.jYear(); // 1360
m.jMonth(); // 4
m.jDate(); // 26
m.jDayOfYear(); // 150
m.jWeek(); // 22
m.jWeekYear(); // 1360
m.add(1, 'jYear');
m.add(2, 'jMonth');
m.format('jYYYY/jM/jD'); // 1361/7/26
m.jMonth(11);
m.startOf('jMonth');
m.format('jYYYY/jM/jD'); // 1361/12/1
m.jYear(1392);
m.startOf('jYear');
m.format('jYYYY/jM/jD'); // 1392/1/1
moment('1391/12/30', 'jYYYY/jMM/jDD').isValid(); // true (leap year)
moment('1392/12/30', 'jYYYY/jMM/jDD').isValid(); // false (common year)
moment.jIsLeapYear(1391); // true
moment.jIsLeapYear(1392); // false
moment('1392/6/3 16:40', 'jYYYY/jM/jD HH:mm').format('YYYY-M-D HH:mm:ss'); // 2013-8-25 16:40:00
moment('2013-8-25 16:40:00', 'YYYY-M-D HH:mm:ss').endOf('jMonth').format('jYYYY/jM/jD HH:mm:ss'); // 1392/6/31 23:59:59
// Complex parse:
moment('1981 5 17', 'YYYY jM D').format('YYYY/MM/DD'); // 1981/07/17
To add Persian language, use loadPersian method:
moment.loadPersian()
MIT
FAQs
Jalaali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js.
The npm package moment-jalaali receives a total of 15,297 weekly downloads. As such, moment-jalaali popularity was classified as popular.
We found that moment-jalaali demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.