Arun
Arun

Reputation: 97

how to convert Hijari date into Gregorian date in javascript?

I am using intalio editor in that I want to convert the Hijri date into a Gregorian date or vice-versa. we write code in javascript using jsx3 so please help me.

Upvotes: 6

Views: 8145

Answers (4)

kerbrose
kerbrose

Reputation: 1185

In Javascript the correct way for such conversion is to use Intl object (read more) as following:

a = new Date();
localeFormat= 'ar-SA-islamic-umalqura';
Intl.DateTimeFormat(localeFormat).format(a)

Upvotes: 0

peller
peller

Reputation: 4543

Try dojox.date.islamic

Upvotes: 1

slebetman
slebetman

Reputation: 113866

It helps to know that muslims refer to the Gregorian calendar as Masihi. Googling for "hijrah to masihi converter" turns up this page as the second hit: http://www.islamicity.com/PrayerTimes/defaultHijriConv.asp

The javascript is code contains two functions GregToIsl and IslToGreg that does what you want.

There is a copyright notice on that page so you shouldn't simply copy-paste the code. But the functions are short enough for you to extract the relevant maths out of.

The maths/algorithm itself is almost a thousand years old so it shouldn't have any legal restriction.

Upvotes: 1

The Archetypal Paul
The Archetypal Paul

Reputation: 41749

For Gregorian->Hijiri, see here

Bidirectional C# version here that could be converted to Javascript

EDIT: An excellent page and convertors can be found here. That page says:

All calculations are done in JavaScript executed in your own browser; complete source code is embedded in or linked to this page, and you're free to download these files to your own computer and use them even when not connected to the Internet.

which suggests to me you can use the code, but you probably want to check with the page author

Upvotes: 3

Related Questions