islamic-network / api.aladhan.com

The AlAdhan API
GNU General Public License v3.0
118 stars 30 forks source link

Redo date calculations with IntlDateTimeFormatter #29

Open meezaan opened 4 years ago

meezaan commented 4 years ago

Like this example:

$DateTime = new DateTime();
$IntlDateFormatter = new IntlDateFormatter(
                    'en_US@calendar=islamic-civil', // or islamic
                    IntlDateFormatter::FULL,
                    IntlDateFormatter::FULL,
                    'Asia/Tehran',
                    IntlDateFormatter::TRADITIONAL);

echo $IntlDateFormatter->format($DateTime);
papasmile commented 4 years ago

Salam, @meezaan couple questions: 1) Are you talking about timings/v1/prayerTimes.php, timings/v1/dateAndTime.php, or other routes as well? 2) Are you thinking to change the output of any of those routes, or just internal calculations?

meezaan commented 4 years ago

No, this refers to https://github.com/islamic-network/api.aladhan.com/blob/master/src/AlAdhanApi/Model/HijriCalendarService.php in general. There are always discrepancies with Hijri dates.

The IntlDateFormatterseemed a better approach but it also has discrepancies, so I'm in 2 minds about whether to do this or not. I've started work on a library try and reconcile the differences, but have not got very far.