How to Calculate Islamic Prayer Times
The following equations may be used to calculate the prayer times; copied from a WEB site which I do not remember from where. I still could not figure out how it generates the times.
One should know a little about the Islamic Prayer times to understand the concept behind these calculations. Basicly, Islamic Prayer times are location and date specific. A calculator for general use must have a location input and a date input. Location should be in terms of meridian and parallel of a city (for instance). The calculator then calculates the sun's movement based on the location and the date entered by the user; and then generates the prayer time. The time pattern is quite complex but of course there is a logic behind it.
Here is the calculation:
(R-L) T
Z = 12+ ----- + --- ........1
15 60
1 {sin(-0.8333-0.0347(H)^0.5)}-sinD.sinB
U= -- arccos -------------------------------------- ........2
15 cosD.cosB
1 -sinG-sinD.sinB
V= -- arccos --------------- ........3
15 cosD.cosB
1 sin{arccot(1+tan(B-D)}-sinD.sinB
W= -- arccos -------------------------------- ........4
15 cosD.cosB
1 sin{arccot(2+tan(B-D)}-sinD.sinB
X= -- arccos -------------------------------- ........5
15 cosD.cosB
where
B= latitude of place
L= longitude of place
R= reference longitude (i.e. TIME BAND x 15)
H= height above sea level in metres
D= declination angle of sun from celestial equator (-ve in southern hemisphere)
T= equation of time
G= twilight angle
'Names of prayer times:
Fajr = Z-V
Sunrise = Z-U
Zuhr = Z
Asr1 (Shafi) = Z+W
Asr2 (Hanafi) = Z+X
Maghrib/Sunset = Z+U
Isha = Z+V
The algorithms to calculate T and D are not shown here. These algorithms may be found in, for example, Jean Meeus' Astronomical Algorithms. Zuhr time is calculated using equation 1. The time for sunrise and sunset/ maghrib may be calculated by subtracting or adding 'U'(obtained from equation 2) to the Zuhr time respectively.
Fajr and Isha times may be calculated by subtracting or adding 'V' (obtained from equation 3) to the Zuhr time respectively. The term G (twilight angle) in equation 3 is usually set to 18 degrees. For a location with an extreme latitude, days in summer may be so long that twilight persists between sunset and the next sunrise. Under these circumstances, 'V' is undefined and Fajr and Isha have to be determined using agreed principles of fiqh.
The start of Asr time (Shafi) may be obtained by adding 'W' (obtained from equation 4) to Zuhr; Asr time (Hanafi) is calculated by adding 'X' (obtained from equation 5) to Zuhr.
----------------------------end of post------------------------------
Islamic Prayer Times - lookup table
Also, for smart_storm's problem, described above, an example can be as below.
Example: Starting from today,16.02.2006, prayer time table for the next 30 days for location: Los Angeles/USA is as below (actual times). Let say these times and dates are in an eeprom.
(six times instead of five times are given)
Date-----Time1,Time2,Time3,Time4,Time5,Time6
-------------------------------------------------
16.02.2006 5 08 6 32 12 14 15 17 17 44 18 58
17.02.2006 5 07 6 31 12 14 15 17 17 45 18 59
18.02.2006 5 06 6 30 12 14 15 18 17 46 19 00
19.02.2006 5 05 6 29 12 14 15 19 17 46 19 00
20.02.2006 5 04 6 28 12 14 15 19 17 47 19 01
21.02.2006 5 03 6 27 12 14 15 20 17 48 19 02
22.02.2006 5 02 6 26 12 14 15 20 17 49 19 03
23.02.2006 5 01 6 25 12 13 15 21 17 50 19 04
24.02.2006 5 00 6 23 12 13 15 22 17 51 19 04
25.02.2006 4 59 6 22 12 13 15 22 17 52 19 05
26.02.2006 4 58 6 21 12 13 15 23 17 53 19 06
27.02.2006 4 57 6 20 12 13 15 23 17 54 19 07
28.02.2006 4 55 6 19 12 13 15 24 17 54 19 08
01.03.2006 4 54 6 17 12 12 15 24 17 55 19 09
02.03.2006 4 53 6 16 12 12 15 25 17 56 19 09
03.03.2006 4 52 6 15 12 12 15 25 17 57 19 10
04.03.2006 4 50 6 14 12 12 15 26 17 58 19 11
05.03.2006 4 49 6 12 12 12 15 26 17 59 19 12
06.03.2006 4 48 6 11 12 11 15 27 17 59 19 13
07.03.2006 4 47 6 10 12 11 15 27 18 00 19 13
08.03.2006 4 45 6 09 12 11 15 27 18 01 19 14
09.03.2006 4 44 6 07 12 11 15 28 18 02 19 15
10.03.2006 4 43 6 06 12 10 15 28 18 03 19 16
11.03.2006 4 41 6 05 12 10 15 29 18 04 19 17
12.03.2006 4 40 6 03 12 10 15 29 18 04 19 18
13.03.2006 4 39 6 02 12 10 15 29 18 05 19 18
14.03.2006 4 37 6 01 12 09 15 30 18 06 19 19
15.03.2006 4 36 5 59 12 09 15 30 18 07 19 20
16.03.2006 4 35 5 58 12 09 15 30 18 08 19 21
17.03.2006 4 33 5 57 12 09 15 31 18 08 19 22
If you check the table carefully, minutes sometime shift for 2 and 3 minutes; not for one minute everyday; or they do not change for two-three days. Lets not think about this part much, unlike the previous post, as they will be prepared to be read.
Given the table, smart_storm can write a clock code and match the hour and minute with the lookup table from eeprom.
For instance, on date 16.02.2006, Time1=5:08 (actualy 05:08 morning time) so that we can store this in time1 and time1x variables as 05 and 08 respectively.
Time1 holds the hour and time1x holds the minute from eeprom lookup table.
If we also use an RTC chip such as DS1302 for instance, and hold the hour and minute in variables DShour and DSminute then we can come up with a sample concept as below.
DShour var byte 'variable: hour from DS1302
DSminute var byte 'variable: minute from DS1302
time1 var byte ' variable: one of six times in a day to store hour from eeprom lookup table.
time1x var byte 'variable: the sister variable of time1 variable to store the minute from eeprom lookup table.
time2 var byte 'other time etc..
time2x var byte '...etc
.....etc.
loop:
gosub read_ds1302 'codes for reading DS1302...
gosub read_eeprom 'codes for reading eeprom lookup table....
gosub do_convertion 'HEX and DEC convertions are done...
If DShour=time1 AND DSminute=time1x then GOSUB buzzer 'to match the time from DS1302 with the time from eeprom, and ifthey match buzz the buzzer.
goto loop
Hope this post and the previous one can help people write a code for prayer times.