npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

moment-jalaali-react-native-calendar

v1.0.3

Published

Jalaali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js.

Downloads

8

Readme

moment-jalaali

A Jalaali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js.

Build Status

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 = require('moment-jalaali')
moment().format('jYYYY/jM/jD')

Browser

You may use the node_modules/build/moment-jalaali.js file.

<script src="node_modules/moment/moment.min.js"></script>
<script src="node_modules/moment-jalaali/build/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 = 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.add(3, 'day')
m.format('jYYYY/jM/jD') // 1361/7/29

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

m.subtract(1, 'jYear')
m.subtract(1, 'jMonth')
m.format('jYYYY/jM/jD') // 1390/12/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.jDaysInMonth(1395, 11) // 30
moment.jDaysInMonth(1394, 11) // 29

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([options])

Options

| Param | Type | Default | Description | Example | | ---------------- | ------- | ------- | ---------------------------------------- | -------------------------------------------- | | usePersianDigits | Boolean | false | Use persian digits (Use at your own risk) | moment.loadPersian({usePersianDigits: true}) | | dialect * | String | persian | Available values = persian, persian-modern | moment.loadPersian({dialect: 'persian-modern'}) |

*use dialect option to change usePersian dialect, available options are:

  • persian: default dialect(امرداد، آدینه، ...)
  • persian-modern: modern dialect(مرداد، جمعه، ...)

Related Projects

react-advance-jalaali-datepicker

A React module, which provides different jalaali (persian) datepicker types such as, range date and time picker, developed base on moment-jalaali. react-advance-jalaali-datepicker created by @A-Kasaaian.

ng-jalali-flat-datepicker

A lightweight angular.js date picker using moment-jalaali is thg303/ng-jalali-flat-datepicker created by @thg303.

pholiday

A library based on moment-jalaali for calculating holidays in Persian calendar is shkarimpour/pholiday created by @shkarimpour.

moment-hijri

Another calendar system plugin for momentjs is moment-hijri created by @xsoh.

vue-persian-datetime-picker

vue-persian-datetime-picker is a vuejs plugin to select jalali date and time, created by @talkhabi.

react-native-general-calendars

react-native-general-calendars is a react-native component with support of gregorian, jalaali and hijri calendar to selectand work with date and time, created by @rghorbani.

License

MIT