For my History of Engineering course, I was reading about how studying astronomy and mathematics helped early Muslims calculate prayer times. Since they did not have graphing calculators back then, large tables with precomputed values were used. I thought it would be interesting to make a program to calculate these times for a given location and date.

Here's what I have so far:

The user configurable settings are stored in ʟAZAN most importantly stores the current time zone, longitude, and latitude. Since different schools calculate the times slightly differently, the remaining elements allow the user to configure those options. I will add a setup menu to make configuring these settings easier in the future.

Most of the equations that I used can be found here. The equation stored in Y₁ calculates the time of day that the sun is at a particular angle. The equation in Y₂ calculates the time at which an object's shadow reaches a particular length. There is a slight error in the way PrayerTimes.org page says to use this equation since the shadow must not only be the length of the object - but the length of the object plus half its shadow length at noon. The shadow length at noon depends both on the declination of the sun and the latitude.

The calculated times seem to match pretty well with times from online prayer time calculators, but the Isha time is still pretty far off (~20 minutes). This could be because some calculators add extra time to this number to ensure that the Belt of Venus (red glow on opposite side of the sky) is no longer visible.

I have included three preconstructed lists with settings for Mecca, Phoenix, and New York. I selected the Fajr and Isha angles based on the conventions used by prominent Muslim organizations in those locations.

Here's what I have so far:

**Code:**```
// |LAZAN:
```

// 1: Time zone

// 2: Longitude

// 3: Latitude

// 4: Elevation in meters

// 5: Fajr Angle

// 6: Isha Angle

// 7: Asr mode 1:obj+nshadow/2, 2:2*obj+nshadow/s

// 8: Maghrib mode: 0=Sunni, 1=Shia

// Presets:

// Mecca{3,39.826168,21.42251,300,18,17,1,0->|LAZAN

// Phoenix{~7,~112.074,33.4484,300,15,15,1,0->|LAZAN

// New York

{~4,~73.935,40.731,7,15,15,1,0->|LAZAN

Degree

Func

getDate->L1

getTime->L2

dbd(101,100*L1(3)+L1(2)+(L1(1)-2000)/100)+(L2(1)-|LAZAN(1)-12)/24->T //days since noon 1 Jan 2000 UTC

357.529+.98560028*T->G

280.459+.98564736*T->Q

Q+1.915sin(G)+.020sin(2G->L

1.00014-0.01671cos(G)-.00014cos(2G->R

23.439-36|E~8T->F

sin^-1(sin(F)sin(L->D // declination of sun

Q/15-R>Ptheta(cos(L),cos(F)sin(L))/15->E // equation of time

// Dhuhr

12+|LAZAN(1)-|LAZAN(2)/15-E/3600->H

// T

"1/15*cos^-1((~sin(X)-sin(L)sin(D))/(cos(L)cos(D"->{Y1}

{Y1}(.833+.0347sqrt(|LAZAN(4->I

// Sunrise

H-I->A

// Sunset

H+I->B

// Fajr

H-{Y1}(~|LAZAN(5->F

// Isha

H+{Y1}(~|LAZAN(6->I

"1/15*cos^-1((sin(tan^-1((X+tan(L-D))^^-1))-sin(L)sin(D))/(cos(L)cos(D"->{Y2}

// Asr

1/tan(90-abs(|LAZAN(3)-D))->L

H+{Y2}(L/2+|LAZAN(7->S

// Maghrib

If |LAZAN(8

Then

H+{Y1}(4->M

Else

B->M

End

// Midnight

12+.5(A+B

Ans-24(Ans>24->O

ClrHome

Disp "Fajr","Sunrise","Dhuhr","Asr","Sunset","Maghrib","Isha'a"

Output(8,1,"Midnight

{F,A,H,S,B,M,I,O->L1

For(N,1,8

Output(N,10+(L1(N)<=9),int(L1(N

Output(N,12,":0

int(60fPart(L1(N

Output(N,13+(Ans<=9),Ans

End

Pause

The user configurable settings are stored in ʟAZAN most importantly stores the current time zone, longitude, and latitude. Since different schools calculate the times slightly differently, the remaining elements allow the user to configure those options. I will add a setup menu to make configuring these settings easier in the future.

Most of the equations that I used can be found here. The equation stored in Y₁ calculates the time of day that the sun is at a particular angle. The equation in Y₂ calculates the time at which an object's shadow reaches a particular length. There is a slight error in the way PrayerTimes.org page says to use this equation since the shadow must not only be the length of the object - but the length of the object plus half its shadow length at noon. The shadow length at noon depends both on the declination of the sun and the latitude.

The calculated times seem to match pretty well with times from online prayer time calculators, but the Isha time is still pretty far off (~20 minutes). This could be because some calculators add extra time to this number to ensure that the Belt of Venus (red glow on opposite side of the sky) is no longer visible.

I have included three preconstructed lists with settings for Mecca, Phoenix, and New York. I selected the Fajr and Isha angles based on the conventions used by prominent Muslim organizations in those locations.