Closed hammady closed 1 year ago
Now we can sort prayers in a reliable way (integer sort!) by sorting on the new field: seconds_since_midnight_utc
. This is guaranteed to have an integer >= 0. When parsing fails, it defaults to the next midnight (minus 1 minute) to ensure it appears at the very end. Important: This is the number of seconds since the previous UTC midnight. It may be > 86400 (seconds in 1 day) if the local time zone lies in the previous day. It cannot be < 0. In summary, it is suitable to sort all prayers in the same day in any timezone.
Not only we can now sort reliably, but we can correctly detect the next prayer and show how many minutes remaining for each masjid in the next prayer table! Just make sure you get the current time in UTC. Also note that this current time could be in the next day of the displayed times. You will notice that it could be 2 pm at your local time zone, but it shows next prayer is Isha (8 pm) which is correct because displayed times are in a different time zone.
Here is the new schema:
{
"masjids": {
"AlfalahICNA": {
"display_name": "Al Falah Islamic Centre",
"website": "https://alfalahcentre.ca/",
"address": "391 Burnhamthorpe Rd E, Oakville, ON L6H 7B4",
"iqamas": {
"fajr": {
"time": "6:45 AM",
"seconds_since_midnight_utc": 38700
},
"zuhr": {
"time": "1:40 PM",
"seconds_since_midnight_utc": 63600
},
"asr": {
"time": "4:30 PM",
"seconds_since_midnight_utc": 73800
},
"maghrib": {
"time": "6:22 PM",
"seconds_since_midnight_utc": 80520
},
"isha": {
"time": "8:00 PM",
"seconds_since_midnight_utc": 86400
}
},
"jumas": [
"First Prayer: 12:15 PM",
"Second Prayer: 1:30 PM",
"Third Prayer: 2:30PM"
],
"last_updated": "2023-10-28T18:58:28.962143"
},
"Alfarooq": {
"display_name": "Masjid Al-Farooq",
"website": "https://www.masjidfarooq.com/",
"address": "935 Eglinton Ave W, Mississauga, ON L5V 1R6",
"iqamas": {
"fajr": {
"time": "6:45 am",
"seconds_since_midnight_utc": 38700
},
"zuhr": {
"time": "1:40 pm",
"seconds_since_midnight_utc": 63600
},
"asr": {
"time": "4:15 pm",
"seconds_since_midnight_utc": 72900
},
"maghrib": {
"time": "6:22 pm",
"seconds_since_midnight_utc": 80520
},
"isha": {
"time": "8:00 pm",
"seconds_since_midnight_utc": 86400
}
},
"jumas": [
"First Prayer: 1:00 pm",
"Second Prayer: 2:00 pm",
"Third Prayer: 3:00 pm"
],
"last_updated": "2023-10-28T18:58:28.962143"
},
"ARIC": {
"display_name": "Ar-Rehman Islamic Center",
"website": "https://aric-icna.ca/",
"address": "6120 Montevideo Rd, Mississauga, ON L5N 3W5",
"iqamas": {
"fajr": {
"time": "6:45 am",
"seconds_since_midnight_utc": 38700
},
"zuhr": {
"time": "1:45 pm",
"seconds_since_midnight_utc": 63900
},
"asr": {
"time": "4:30 pm",
"seconds_since_midnight_utc": 73800
},
"maghrib": {
"time": "5 minutes After Azaan",
"seconds_since_midnight_utc": 100740
},
"isha": {
"time": "8:00 pm",
"seconds_since_midnight_utc": 86400
}
},
"jumas": [
"1st: Khutbah: 01:05 pm - Jammah: 01:25 pm",
"2nd: Khutbah: 01:40 pm - Jammah: 02:00 pm",
"3rd: Khutbah: 02:15 pm - Jammah: 02:35 pm",
"4th: Khutbah: 02:50 pm - Jammah: 03:10 pm"
],
"last_updated": "2023-10-28T18:58:28.962143"
},
"DarFoundation": {
"display_name": "Dar Foundation",
"website": "https://darfoundation.com/",
"address": "485 Morden Rd, Oakville, ON, L6K 3W6",
"iqamas": {
"fajr": {
"time": "6:45 AM",
"seconds_since_midnight_utc": 38700
},
"zuhr": {
"time": "1:45 PM",
"seconds_since_midnight_utc": 63900
},
"asr": {
"time": "4:15 PM",
"seconds_since_midnight_utc": 72900
},
"maghrib": {
"time": "6:22 PM",
"seconds_since_midnight_utc": 80520
},
"isha": {
"time": "7:45 PM",
"seconds_since_midnight_utc": 85500
}
},
"jumas": [
"First Prayer: 12:15 PM",
"Second Prayer: 1:30 PM",
"Third Prayer: 2:30 PM",
"Fourth Prayer: 3:30 PM"
],
"last_updated": "2023-10-28T18:58:28.962143"
},
"ICCO": {
"display_name": "Islamic Community Centre of Ontario",
"website": "https://centres.macnet.ca/icco/",
"address": "2550 Dunwin Dr, Mississauga, ON L5L 1T1",
"iqamas": {
"fajr": {
"time": "6:45 am",
"seconds_since_midnight_utc": 38700
},
"zuhr": {
"time": "2:00 pm",
"seconds_since_midnight_utc": 64800
},
"asr": {
"time": "4:45 pm",
"seconds_since_midnight_utc": 74700
},
"maghrib": {
"time": "6:23 pm",
"seconds_since_midnight_utc": 80580
},
"isha": {
"time": "8:00 pm",
"seconds_since_midnight_utc": 86400
}
},
"jumas": [
"12:30 P.M. by Yasser Albaz (English)",
"1:30 P.M. by Baker Baker (English)",
"2:45 P.M. by Sheikh Samir Khalil (Arabic)"
],
"last_updated": "2023-10-28T18:58:28.962143"
},
"ISNACanada": {
"display_name": "ISNA Canada - ICC",
"website": "https://www.isnacanada.com/",
"address": "2200 S Sheridan Way, Mississauga, ON L5J 2M4",
"iqamas": {
"fajr": {
"time": "6:30 AM",
"seconds_since_midnight_utc": 37800
},
"zuhr": {
"time": "1:30 PM",
"seconds_since_midnight_utc": 63000
},
"asr": {
"time": "4:45 PM",
"seconds_since_midnight_utc": 74700
},
"maghrib": {
"time": "6:23 PM",
"seconds_since_midnight_utc": 80580
},
"isha": {
"time": "8:00 PM",
"seconds_since_midnight_utc": 86400
}
},
"jumas": [
"First Prayer: 1:40 PM",
"Second Prayer: 3:00 PM"
],
"last_updated": "2023-10-28T18:58:28.962143"
},
"MNNexus": {
"display_name": "Muslim Neighbour Nexus (MNN)",
"website": "https://mnnexus.ca/",
"address": "3520 Odyssey Dr, Mississauga, ON L5M 0Y9",
"iqamas": {
"fajr": {
"time": "6:45 am",
"seconds_since_midnight_utc": 38700
},
"zuhr": {
"time": "1:45 pm",
"seconds_since_midnight_utc": 63900
},
"asr": {
"time": "4:45 pm",
"seconds_since_midnight_utc": 74700
},
"maghrib": {
"time": "6:18 pm",
"seconds_since_midnight_utc": 80280
},
"isha": {
"time": "8:00 pm",
"seconds_since_midnight_utc": 86400
}
},
"jumas": [
"1:15 pm - Muslim Neighbour Nexus, 3520 Odyssey Dr, Mississauga, ON L5M 0Y9",
"2:15 pm - Muslim Neighbour Nexus, 3520 Odyssey Dr, Mississauga, ON L5M 0Y9",
"3:00 pm - Muslim Neighbour Nexus, 3520 Odyssey Dr, Mississauga, ON L5M 0Y9",
"1:30 pm - Churchill Meadows Community Centre 5320 Ninth Line, Mississauga, ON L5M 0R5",
"2:15 pm - Churchill Meadows Community Centre 5320 Ninth Line, Mississauga, ON L5M 0R5"
],
"last_updated": "2023-10-28T18:58:28.962143"
},
"Shalimar": {
"display_name": "Shalimar Islamic Centre",
"website": "https://www.shalimarislamiccentre.ca/",
"address": "79-3024 Cedarglen Gate, Mississauga, ON, L5C 4S3",
"iqamas": {
"fajr": {
"time": "6:45 am",
"seconds_since_midnight_utc": 38700
},
"zuhr": {
"time": "1:40 pm",
"seconds_since_midnight_utc": 63600
},
"asr": {
"time": "4:30 pm",
"seconds_since_midnight_utc": 73800
},
"maghrib": {
"time": "6:30 pm",
"seconds_since_midnight_utc": 81000
},
"isha": {
"time": "08:15 pm",
"seconds_since_midnight_utc": 87300
}
},
"jumas": [
"12:35 pm - Shalimar. Walk-in. Come 5 mins early.",
"1:35 pm - Shalimar. Walk-in. Come 5 mins early."
],
"last_updated": "2023-10-28T18:58:28.962143"
},
"WestEndIslamicCenter": {
"display_name": "West End Islamic Center",
"website": "https://weicenter.ca/",
"address": "12,13-4161 Sladeview Crescent, Mississauga, ON L5L 5R3",
"iqamas": {
"fajr": {
"time": "6:40 AM",
"seconds_since_midnight_utc": 38400
},
"zuhr": {
"time": "2:00 PM",
"seconds_since_midnight_utc": 64800
},
"asr": {
"time": "5:00 PM",
"seconds_since_midnight_utc": 75600
},
"maghrib": {
"time": "6:18 PM",
"seconds_since_midnight_utc": 80280
},
"isha": {
"time": "8:30 PM",
"seconds_since_midnight_utc": 88200
}
},
"jumas": [
"1st PrayerKhutbah - 1:30 PM - English",
"2nd PrayerKhutbah - 2:30 PM - Urdu",
"3rd PrayerKhutbah - 3:20 PM - English"
],
"last_updated": "2023-10-28T18:58:28.962143"
}
}
}
Now we can sort prayers in a reliable way (integer sort!) by sorting on the new field:
seconds_since_midnight_utc
. This is guaranteed to have an integer >= 0. When parsing fails, it defaults to the next midnight (minus 1 minute) to ensure it appears at the very end. Important: This is the number of seconds since the previous UTC midnight. It may be > 86400 (seconds in 1 day) if the local time zone lies in the previous day. It cannot be < 0. In summary, it is suitable to sort all prayers in the same day in any timezone.Not only we can now sort reliably, but we can correctly detect the next prayer and show how many minutes remaining for each masjid in the next prayer table! Just make sure you get the current time in UTC. Also note that this current time could be in the next day of the displayed times. You will notice that it could be 2 pm at your local time zone, but it shows next prayer is Isha (8 pm) which is correct because displayed times are in a different time zone.
Here is the new schema:
{ "masjids": { "AlfalahICNA": { "display_name": "Al Falah Islamic Centre", "website": "https://alfalahcentre.ca/", "address": "391 Burnhamthorpe Rd E, Oakville, ON L6H 7B4", "iqamas": { "fajr": { "time": "6:45 AM", "seconds_since_midnight_utc": 38700 }, "zuhr": { "time": "1:40 PM", "seconds_since_midnight_utc": 63600 }, "asr": { "time": "4:30 PM", "seconds_since_midnight_utc": 73800 }, "maghrib": { "time": "6:22 PM", "seconds_since_midnight_utc": 80520 }, "isha": { "time": "8:00 PM", "seconds_since_midnight_utc": 86400 } }, "jumas": [ "First Prayer: 12:15 PM", "Second Prayer: 1:30 PM", "Third Prayer: 2:30PM" ], "last_updated": "2023-10-28T18:58:28.962143" }, "Alfarooq": { "display_name": "Masjid Al-Farooq", "website": "https://www.masjidfarooq.com/", "address": "935 Eglinton Ave W, Mississauga, ON L5V 1R6", "iqamas": { "fajr": { "time": "6:45 am", "seconds_since_midnight_utc": 38700 }, "zuhr": { "time": "1:40 pm", "seconds_since_midnight_utc": 63600 }, "asr": { "time": "4:15 pm", "seconds_since_midnight_utc": 72900 }, "maghrib": { "time": "6:22 pm", "seconds_since_midnight_utc": 80520 }, "isha": { "time": "8:00 pm", "seconds_since_midnight_utc": 86400 } }, "jumas": [ "First Prayer: 1:00 pm", "Second Prayer: 2:00 pm", "Third Prayer: 3:00 pm" ], "last_updated": "2023-10-28T18:58:28.962143" }, "ARIC": { "display_name": "Ar-Rehman Islamic Center", "website": "https://aric-icna.ca/", "address": "6120 Montevideo Rd, Mississauga, ON L5N 3W5", "iqamas": { "fajr": { "time": "6:45 am", "seconds_since_midnight_utc": 38700 }, "zuhr": { "time": "1:45 pm", "seconds_since_midnight_utc": 63900 }, "asr": { "time": "4:30 pm", "seconds_since_midnight_utc": 73800 }, "maghrib": { "time": "5 minutes After Azaan", "seconds_since_midnight_utc": 100740 }, "isha": { "time": "8:00 pm", "seconds_since_midnight_utc": 86400 } }, "jumas": [ "1st: Khutbah: 01:05 pm - Jammah: 01:25 pm", "2nd: Khutbah: 01:40 pm - Jammah: 02:00 pm", "3rd: Khutbah: 02:15 pm - Jammah: 02:35 pm", "4th: Khutbah: 02:50 pm - Jammah: 03:10 pm" ], "last_updated": "2023-10-28T18:58:28.962143" }, "DarFoundation": { "display_name": "Dar Foundation", "website": "https://darfoundation.com/", "address": "485 Morden Rd, Oakville, ON, L6K 3W6", "iqamas": { "fajr": { "time": "6:45 AM", "seconds_since_midnight_utc": 38700 }, "zuhr": { "time": "1:45 PM", "seconds_since_midnight_utc": 63900 }, "asr": { "time": "4:15 PM", "seconds_since_midnight_utc": 72900 }, "maghrib": { "time": "6:22 PM", "seconds_since_midnight_utc": 80520 }, "isha": { "time": "7:45 PM", "seconds_since_midnight_utc": 85500 } }, "jumas": [ "First Prayer: 12:15 PM", "Second Prayer: 1:30 PM", "Third Prayer: 2:30 PM", "Fourth Prayer: 3:30 PM" ], "last_updated": "2023-10-28T18:58:28.962143" }, "ICCO": { "display_name": "Islamic Community Centre of Ontario", "website": "https://centres.macnet.ca/icco/", "address": "2550 Dunwin Dr, Mississauga, ON L5L 1T1", "iqamas": { "fajr": { "time": "6:45 am", "seconds_since_midnight_utc": 38700 }, "zuhr": { "time": "2:00 pm", "seconds_since_midnight_utc": 64800 }, "asr": { "time": "4:45 pm", "seconds_since_midnight_utc": 74700 }, "maghrib": { "time": "6:23 pm", "seconds_since_midnight_utc": 80580 }, "isha": { "time": "8:00 pm", "seconds_since_midnight_utc": 86400 } }, "jumas": [ "12:30 P.M. by Yasser Albaz (English)", "1:30 P.M. by Baker Baker (English)", "2:45 P.M. by Sheikh Samir Khalil (Arabic)" ], "last_updated": "2023-10-28T18:58:28.962143" }, "ISNACanada": { "display_name": "ISNA Canada - ICC", "website": "https://www.isnacanada.com/", "address": "2200 S Sheridan Way, Mississauga, ON L5J 2M4", "iqamas": { "fajr": { "time": "6:30 AM", "seconds_since_midnight_utc": 37800 }, "zuhr": { "time": "1:30 PM", "seconds_since_midnight_utc": 63000 }, "asr": { "time": "4:45 PM", "seconds_since_midnight_utc": 74700 }, "maghrib": { "time": "6:23 PM", "seconds_since_midnight_utc": 80580 }, "isha": { "time": "8:00 PM", "seconds_since_midnight_utc": 86400 } }, "jumas": [ "First Prayer: 1:40 PM", "Second Prayer: 3:00 PM" ], "last_updated": "2023-10-28T18:58:28.962143" }, "MNNexus": { "display_name": "Muslim Neighbour Nexus (MNN)", "website": "https://mnnexus.ca/", "address": "3520 Odyssey Dr, Mississauga, ON L5M 0Y9", "iqamas": { "fajr": { "time": "6:45 am", "seconds_since_midnight_utc": 38700 }, "zuhr": { "time": "1:45 pm", "seconds_since_midnight_utc": 63900 }, "asr": { "time": "4:45 pm", "seconds_since_midnight_utc": 74700 }, "maghrib": { "time": "6:18 pm", "seconds_since_midnight_utc": 80280 }, "isha": { "time": "8:00 pm", "seconds_since_midnight_utc": 86400 } }, "jumas": [ "1:15 pm - Muslim Neighbour Nexus, 3520 Odyssey Dr, Mississauga, ON L5M 0Y9", "2:15 pm - Muslim Neighbour Nexus, 3520 Odyssey Dr, Mississauga, ON L5M 0Y9", "3:00 pm - Muslim Neighbour Nexus, 3520 Odyssey Dr, Mississauga, ON L5M 0Y9", "1:30 pm - Churchill Meadows Community Centre 5320 Ninth Line, Mississauga, ON L5M 0R5", "2:15 pm - Churchill Meadows Community Centre 5320 Ninth Line, Mississauga, ON L5M 0R5" ], "last_updated": "2023-10-28T18:58:28.962143" }, "Shalimar": { "display_name": "Shalimar Islamic Centre", "website": "https://www.shalimarislamiccentre.ca/", "address": "79-3024 Cedarglen Gate, Mississauga, ON, L5C 4S3", "iqamas": { "fajr": { "time": "6:45 am", "seconds_since_midnight_utc": 38700 }, "zuhr": { "time": "1:40 pm", "seconds_since_midnight_utc": 63600 }, "asr": { "time": "4:30 pm", "seconds_since_midnight_utc": 73800 }, "maghrib": { "time": "6:30 pm", "seconds_since_midnight_utc": 81000 }, "isha": { "time": "08:15 pm", "seconds_since_midnight_utc": 87300 } }, "jumas": [ "12:35 pm - Shalimar. Walk-in. Come 5 mins early.", "1:35 pm - Shalimar. Walk-in. Come 5 mins early." ], "last_updated": "2023-10-28T18:58:28.962143" }, "WestEndIslamicCenter": { "display_name": "West End Islamic Center", "website": "https://weicenter.ca/", "address": "12,13-4161 Sladeview Crescent, Mississauga, ON L5L 5R3", "iqamas": { "fajr": { "time": "6:40 AM", "seconds_since_midnight_utc": 38400 }, "zuhr": { "time": "2:00 PM", "seconds_since_midnight_utc": 64800 }, "asr": { "time": "5:00 PM", "seconds_since_midnight_utc": 75600 }, "maghrib": { "time": "6:18 PM", "seconds_since_midnight_utc": 80280 }, "isha": { "time": "8:30 PM", "seconds_since_midnight_utc": 88200 } }, "jumas": [ "1st PrayerKhutbah - 1:30 PM - English", "2nd PrayerKhutbah - 2:30 PM - Urdu", "3rd PrayerKhutbah - 3:20 PM - English" ], "last_updated": "2023-10-28T18:58:28.962143" } } }
This is amazing! It opens new possibilities, Thanks @hammady!
@hammady About remaining time to next iqama, how would we add it to the prayers view?
With the introduction of #9, we need to ensure prayer times are sorted correctly as timestamps rather than strings. This avoids cases where 08 coming before 7 and 1 pm coming before 12 pm. Times should be parsed as time components for today and in the correct timezone for each masjid. The output should be the number of seconds since midnight in UTC.