Giter Site home page Giter Site logo

ezamlee / umm-al-qura-calendar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from talomaireeni/umm-al-qura-calendar

0.0 2.0 0.0 124 KB

A javascript library for converting Gregorian date to Hijri date (Umm Al-Qura calculation). This library was adapted from Robert Harry van Gent work. I modified the code a bit to make it stand alone and modular.

License: Apache License 2.0

JavaScript 100.00%

umm-al-qura-calendar's Introduction

Umm Al-Qura Calendar

A javascript library for converting Gregorian date to Hijri date (Umm Al-Qura calculation). This library was adapted from Robert Harry van Gent work. I modified the code a bit to make it stand alone and modular.

What is Hijri Calendar

Well, if you do not know what is Hijri Calendar already then this repo may be not for you. If you insist, it is used by more than a billion Muslims around the world to determine the main days of observance in the Islamic religious year. Although in daily life the Western (Gregorian) calendar is now generally followed, the Islamic lunar calendar has since the days of the prophet Muhammad regulated the key days in the Islamic year such as the start and end (‛Īd al-Fitr) of the month of fasting (Ramadān) and the Day of Sacrifice (‛Īd al-Adhā on 10 Dhū ’l-Hijja) during the annual pilgrimage (hajj) at Mecca. For more info, check out this article.

What is Umm Al-Qura Calendar

It is the official sighting method to determine the beginning and length of each month of the Hijri calendar in Saudi Arabia. It is one method for calculation based on history and other complex stuff. If you live or develop for something to be used in Saudi Arabia, this library will save your time.

What is inside

A single stand alone javascript file. It can be used in any javascript project: Web, Node.js, Appcelerator, PhoneGap, etc. It contains both historical data and calculation algorithms. This code is based on the Umm al-Qura calendar and is valid from 1356 AH (14 March 1937 CE) to 1500 AH (16 November 2077 CE). Outside this interval, the converter will give erroneous results.

Usage

After including the file "UQCal.js", there are two ways to use UQCal: Basic Usage:

var cal = new UQCal(); // assuming today is 28th of December 2013.
var HijriDate = cal.convert();
console.log(HijriDate);
/*
THE RESULT:
{Gday: 28,Gmonth: 12,Gyear: 2013,Hday: 25,Hlength: 29,Hmonth: 2,Hyear: 1435,ilunnum: 17210,julday: 2456655,wkday: 6}
*/

Convert a Specific Date:

var cal = new UQCal('2013-12-20');
var HijriDate = cal.convert();
console.log(HijriDate);
/*
THE RESULT:
{Gday: 20,Gmonth: 12,Gyear: 2013,Hday: 17,Hlength: 29,Hmonth: 2,Hyear: 1435,ilunnum: 17210,julday: 2456647,wkday: 5}
*/

Documentation

The library is simple and self explanatory. The following shows everything you need to know: UQCal Object Construction:

  • var cal = new UQCal(date); date is optional, Defaults to Today's date.

Date Conversion:

  • cal.convert(); where the actual conversion happen.

Output:

NameTypeDescription
GdayIntegerGregorian day.
GmonthIntegerGregorian month.
GyearIntegerGregorian year.
HdayIntegerHijri day.
HmonthIntegerHijri month.
HyearIntegerHijri year.
HlengthIntegerThe length of the Hijri month, 29 or 30.
ilunnumIntegerI have no idea :(
juldayIntegerChronological offset between Julian and Gregorian calendar.
wkdayIntegerNumber of day in the week, Monday being #1.

umm-al-qura-calendar's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.