mptwaktusolat / app_waktu_solat_malaysia

Prayer times app for Malaysia. Accurate data from JAKIM. Install the app on your phones now.
https://play.google.com/store/apps/details?id=live.iqfareez.waktusolatmalaysia
GNU General Public License v3.0
45 stars 21 forks source link

Study how Hijri date is calculated #159

Closed iqfareez closed 1 year ago

iqfareez commented 1 year ago

Background

Currently, we are using data from JAKIM API to get the prayer time alongside with the hijri date. It is fine doing that way, but I'm looking for method to calculate the Hijri date from the Gregorian calendar. The benefit is that we can calculate the hijri date without waiting for JAKIM data.

To solve what?

Urm, maybe nothing. All works fine currently. Perhaps beneficial for future development? It's just I'm looking on a way to get the accurate Hijri date without depending on JAKIM API data. The resulting hijri date still need to be cross check with JAKIM.

iqfareez commented 1 year ago

E-Falak | Jakim

KALENDAR KALKULATOR

Tarikh Miladi - Tarikh Hijri https://www.e-solat.gov.my/index.php?siteId=27&pageId=48

JAKIM provide an online calculator for public to convert the date from miladi to hijri and vice versa. image

Looking at the dropdown menu for the year (shown in the figure below), it is noted that the maximum year available in 2026 (~4 years from now). So, maybe, the takwim is already calculated/determined earlier (not calculated on the fly). I'm still interested how they decide on the takwim assignment though) image

We just need to inser the day, month & year, and click on Tukar (convert). The result will then be shown at the botton.

We can do the same thing in cURL (Replace date with your date of interest).

curl --request GET --url 'https://www.e-solat.gov.my/index.php?r=esolatApi%2Ftarikhtakwim&period=today&datetype=miladi&date=2022-11-29'

Result

{"takwim":{"2022-11-29":"1444-05-04"},"serverTime":"2022-11-29 14:29:11","dateType":"miladi","dateRequest":"2022-11-29","status":"OK!"}

To convert from hijri to miladi, change the datetype to hijri, remove key date and replace with hijri with its date. Example:

https://www.e-solat.gov.my/index.php?r=esolatApi/tarikhtakwim&period=today&datetype=hijri&hijri=1416-01-01

They also hosted an Islamic calendar with the miladi and hijri date altogether. Check out the page at https://www.e-solat.gov.my/index.php?siteId=24&pageId=26. image

This data is fetchable via JAKIM's undocumented API.

curl 'https://www.e-solat.gov.my/index.php?r=esolatApi/tarikhtakwim&period=month&datetype=hijri&hijri=1444-05-04' 

Conclusion

The takwim is determined earlier. No direct formula from Miladi (Gregorian) to Hijri. However, they've mentioned

Kaedah pengiraan yang digunakan adalah kaedah Imkanur Rukyah. Kaedah ini bermula dari tahun 1995 sehingga tahun semasa.

Perhaps I can study about the Imkanur Rukyah to understand how Hijri date is determined.

iqfareez commented 1 year ago

JAKIM is different. Why?

First, take a look at the hijri date from e-solat JAKIM: image

30 November 2022 -> 5 J.Awal

Now, find any Miladi to Hijri converter online to convert the date 30 November.

I tried these services: https://www.dralshehri.com/hijri-converter/ https://pteo.paranoiaworks.mobi/islamic_calendar/ https://www.islamicity.org/hijri-gregorian-converter/?AspxAutoDetectCookieSupport=1# https://mpt-hijri-converter.web.app/#/ (my old web app)

All of them resulting to 6 J.Awwal. JAKIM seems to be lag by one day.

Types of Takwim

Digging through has brought me into Kalkulator Umur Miladi - Hijri by JAKIM.

Just like above, I tried to convert from 30 November 2022 to Hijri. The result as follows: image

6 J.Awwal. Ahh, same result as the other services above. It is different from the main e-solat date. Why? What are the differences? How is the date is determined?

Looking close at the footer:

*Kaedah Pengiraan yang digunakan adalah kaedah kiraan istilahi, terdapat kebarangkalian untuk kesilapan lebih sehari, atau kurang sehari

That's the hint 💡 . The differences are caused by the different kaedah (methods) available.

So, I went to Google to find the relevant information.

Jenis kalendar hijri di Malaysia

Stumble upon some articles explaining the various calculation method to determine the first day of the month.

There are four types of calculation method (as in the figure above). The most basic and classic is Istilahi, like the one used in above calendar conversion and the rest of those online services (Some sites mentioning there are using Umm al-Qura (Saudi Arabia) calendar). From 1995 until today, Malaysia is using the Imkanur Rukyah method. Remember the Raya terkejut? Where suddenly the 'Eid is announced tomorrow. Refer this, this, any maybe this. The relevant authorities look up to find hilal according to this Imkanur Rukyah, the criterion where met hence they announces the eid.

So, IMO, what I can say is the taqwim is pre-determined by JAKIM authorities. So, for Malaysian, for the most accurate Hijri date, please refer to JAKIM.

This is not the end of this study though. I'll keep updated if I found any new information.

iqfareez commented 1 year ago

This repo: https://github.com/iamriajul/adhan-dart is about prayer time calculation. Not sure if it is related to the hijri date. But I'm just gonna leave it here.