All Projects → xsoh → Moment Hijri

xsoh / Moment Hijri

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

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Moment Hijri

Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (+272.22%)
Mutual labels:  moment, calendar
React Input Calendar
Stars: ✭ 138 (-4.17%)
Mutual labels:  moment, calendar
React Datepicker
📅 React DatePicker Library (Flexible, Reusable)
Stars: ✭ 165 (+14.58%)
Mutual labels:  moment, calendar
Moment.php
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Stars: ✭ 900 (+525%)
Mutual labels:  moment, calendar
react-native-daterange-picker
A React Native component for picking date ranges or single dates.
Stars: ✭ 86 (-40.28%)
Mutual labels:  calendar, moment
Pg Calendar
📆 beautiful and eidetic date picker
Stars: ✭ 109 (-24.31%)
Mutual labels:  moment, calendar
Punic
PHP translation and localization made easy!
Stars: ✭ 133 (-7.64%)
Mutual labels:  calendar
React Calendar
Ultimate calendar for your React app.
Stars: ✭ 2,082 (+1345.83%)
Mutual labels:  calendar
Booking App
Laravel 5.1 web application for booking appointments
Stars: ✭ 130 (-9.72%)
Mutual labels:  calendar
Timetable
📅 Customizable flutter calendar widget including day and week views
Stars: ✭ 140 (-2.78%)
Mutual labels:  calendar
Openki
We moved to GitLab 💔 Openki is a tool to build up and organize local communities – Open education for real.
Stars: ✭ 137 (-4.86%)
Mutual labels:  calendar
Devextreme Reactive
Business React components for Bootstrap and Material-UI
Stars: ✭ 1,800 (+1150%)
Mutual labels:  calendar
A Joke
🤡 A-Joke { 一个笑话,目的就是能够在工作之余博君一笑,尽得人生笑开颜 }
Stars: ✭ 135 (-6.25%)
Mutual labels:  moment
Life Calendar
A look at the big picture.
Stars: ✭ 139 (-3.47%)
Mutual labels:  calendar
Flutterweekview
Displays a highly customizable week view (or day view) which is able to display events, to be scrolled, to be zoomed-in & out and a lot more !
Stars: ✭ 130 (-9.72%)
Mutual labels:  calendar
Jscalendar
Just a simple javascript calendar
Stars: ✭ 142 (-1.39%)
Mutual labels:  calendar
Calendarview
Android 平台上继承 View 实现的自定义日历控件
Stars: ✭ 129 (-10.42%)
Mutual labels:  calendar
Jtoday
This is an extremely brief notification center calendar plugin (Swift).
Stars: ✭ 137 (-4.86%)
Mutual labels:  calendar
Zbjcalendar
ZBJCalendar is a simple calendar framework for iOS.
Stars: ✭ 140 (-2.78%)
Mutual labels:  calendar
Khal
📆 CLI calendar application
Stars: ✭ 1,888 (+1211.11%)
Mutual labels:  calendar

NPM version MIT License Build Status

moment-hijri

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.

Upgrading to 2.0.0

Because of Using 'h' specifier might cause overlap with hour's specifier, the specifier has been changed from h to i as a prefix. For example in the previous version to get the four digit year, hYYYY will be used. In version 2.0 or above it should be replaced by iYYYY.

Where to use it?

Like momentjs, moment-hijri works in browser and in Node.js.

Node.js

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

Browser

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

Require.js

require.config({
  paths: {
    "moment": "path/to/moment",
    "moment-hijri": "path/to/moment-hijri"
  }
});
define(["moment-hijri"], 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.format('iYYYY/iM/iD'); // 1411/10/28

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/xsoh/moment-hijri/master/moment-hijri.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 @behrang whose behind moment-jalaali project.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].