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-umm-al-qura

v1.0.3

Published

A Hijri calendar (Based on official Umm al-Qura calculations "KSA") plugin for moment.js.

Downloads

53

Readme

NPM version MIT License

moment-umm-al-qura

A Hijri (Based on Umm al-Qura calculations) calendar system plugin for moment.js.

About

Hijri is the Islamic lunar calendar used by Muslims to determine the proper days on which to observe the annual fasting, to attend Hajj, and to celebrate other Islamic holidays and festivals. More information about Hijri can be found at wikipedia.

This plugin adds Hijri calendar support to momentjs library.

Calendar conversion is based on the Umm al-Qura calculations.

Where to use it?

Like momentjs, moment-umm-al-qura works in browser and in Node.js.

Node.js

npm install moment-umm-al-qura
var moment = require('moment-umm-al-qura');
moment().format('iYYYY/iM/iD');

Browser

<script src="moment.js"></script>
<script src="moment-umm-al-qura.js"></script>
<script>
	moment().format('iYYYY/iM/iD');
</script>

Require.js

require.config({
  paths: {
    "moment": "path/to/moment",
    "moment-umm-al-qura": "path/to/moment-umm-al-qura"
  }
});
define(["moment-umm-al-qura"], function (moment) {
  moment().format('iYYYY/iM/iD');
});

API

This plugin tries to mimic momentjs api. Basically, when formatting or parsing a string, add an i to the format token such as 'iYYYY' or 'iM'. For example:

m = moment('1410/8/28', 'iYYYY/iM/iD'); // Parse a Hijri date.
m.format('iYYYY/iM/iD [is] YYYY/M/D'); // 1410/8/28 is 1990/3/25

m.iYear(); // 1410
m.iMonth(); // 7
m.iDate(); // 28
m.iDayOfYear(); // 236
m.iWeek(); // 35
m.iWeekYear(); // 1410

m.add(1, 'iYear');
m.add(2, 'iMonth');
m.add(1, 'idate');
m.format('iYYYY/iM/iD'); // 1411/10/29

m.iMonth(11);
m.startOf('iMonth');
m.format('iYYYY/iM/iD'); // 1411/12/1

m.iYear(1392);
m.startOf('iYear');
m.format('iYYYY/iM/iD'); // 1420/1/1

moment('1436/1/30', 'iYYYY/iMM/iDD').isValid(); // false (This month is only 29 days).
moment('1436/2/30', 'iYYYY/iMM/iDD').isValid(); // true (This month is 30 days).

moment('1436/2/6 16:40', 'iYYYY/iM/iD HH:mm').format('YYYY-M-D HH:mm:ss'); // 2014-11-28 16:40:00

moment('2014-11-28 16:40:00', 'YYYY-M-D HH:mm:ss').endOf('iMonth').format('iYYYY/iM/iD HH:mm:ss'); // 1436/2/30 23:59:59

// Complex parse:
moment('1990 5 25', 'YYYY iM D').format('YYYY/MM/DD'); // 1990/03/25

To use the Arabic locale:

Here is example:

    <!-- 1- Load the moment-with-locales -->
    <script src="http://momentjs.com/downloads/moment-with-locales.min.js"></script>
    <script src="https://raw.githubusercontent.com/happy-oodiroo/moment-umm-al-qura/master/moment-umm-al-qura.js"></script>
    
    <script>
      moment.locale('ar-SA');// 2- Set the global locale to `ar-SA`
      m = moment();
      m.format('iYYYY/iM/iDهـ الموافق YYYY/M/Dم'); //3- use it normally 
      //١٤٣٧/٨/١٧هـ الموافق ٢٠١٦/٥/٢٤م
    </script>

Acknowledgements

This project was built from the great work done by @xsoh whose behind moment-hijri project.

License

MIT