Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xsoh/Hijri.js
A tool for the Islamic calender (Hijri) in Javascript
https://github.com/xsoh/Hijri.js
calendar gregorian hijri hijri-calendar
Last synced: about 19 hours ago
JSON representation
A tool for the Islamic calender (Hijri) in Javascript
- Host: GitHub
- URL: https://github.com/xsoh/Hijri.js
- Owner: xsoh
- License: other
- Created: 2013-02-10T11:15:07.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2023-01-31T02:50:08.000Z (almost 2 years ago)
- Last Synced: 2024-08-03T11:08:53.089Z (3 months ago)
- Topics: calendar, gregorian, hijri, hijri-calendar
- Language: JavaScript
- Homepage: http://xsoh.github.com/Hijri.js
- Size: 877 KB
- Stars: 73
- Watchers: 7
- Forks: 26
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-arabic - Hijri.js - A tool for Hijri calender (based on Umm al-Qura calculations) in Javascript. (Programming Languages)
- awesome-arabic - Hijri.js - A tool for Hijri calender (based on Umm al-Qura calculations) in Javascript. (Programming Languages)
- Awesome-Muslims - Hijri JS
README
Hijri.js
========A simple implementation for the Islamic calender(Hijri) in Javascript
## The Problem
I made this project just because I did not found any correct and open source Hijri converter. Each time I try one its either stored in database and fetch the data each time or it does not give me the correct date "specially when I try before 1420H"## Usage
### Current Day
To get Today in Hijri:
```html
Today is:
function initWork() {
//Today
var todayElement = document.getElementById("today");
todayElement.innerHTML = HijriJS.today().toString();
}
```
### Conversion
To convert between Hijri and Gregorian use the ``HijriJS.toHijri(dateString, splitter)`` to convert Gregorian to Hijri
or ``HijriJS.toGregorian(dateString, splitter)`` to convert Hijri to Gregorian where the splitter is the symbol splits the date (e.g. for 1434/1/1 is ``HijriJS.toGregorian("1434/1/1", "/")``):
```html
function convertToHijri() {
var gregorianDate = document.getElementById("gregorianInput").value
var hijriDate = document.getElementById("hijriDate");var date = HijriJS.toHijri(gregorianDate, "/");
hijriDate.innerHTML = date.toString();
}
```
### Formating
More advanced is to print the date with different format you can use ``date.toFormat(yourStringFormat);`` where yourStringFormat can be:
- **YYYY**: For the four digit year notation e.g. 1434.
- **YY**: For two year notation e.g. 34 of 1434.
- **mm**: For two digit month notation e.g. 03.
- **m**: For one digit month notation e.g. 3.
- **dd**: For two digit day notation.
- **d**: For one digit day notation.
- **n**: For calender notation "H for Hijri or G for Gregorian".You can use the same example above and change it like this:
```javascriptfunction convertToHijri() {
var gregorianDate = document.getElementById("gregorianInput").value
var hijriDate = document.getElementById("hijriDate");var date = HijriJS.toHijri(gregorianDate, "/");
hijriDate.innerHTML = date.toFormat("dd/mm/yyyyN");
}```