#!/usr/local/bin/perl # # (c), Written by Sobhi Nahle..1999-1419 AH sub asin { atan2($_[0], sqrt(1 - $_[0] * $_[0])) } sub acos { atan2( sqrt(1 - $_[0] * $_[0]), $_[0] ) } sub tan { sin($_[0]) / cos($_[0]) } # # (c), Written by Sobhi Nahle..1999-1419 AH print "Content-type: text/html\n\n"; print ""; print ""; print "Prayer Time Schedule"; print ""; print "
Make your own free website on Tripod.com
"; #Read form data into $form_data read(STDIN, $form_data, $ENV{"CONTENT_LENGTH"}); #Split the string at each "&", put all name/value pairs into #the array @name-value-pairs. @name_value_pairs=split(/&/,$form_data); #Loop thru each pair .."name=value" split into name and value #and decode them.. foreach $pair (@name_value_pairs) { #Split the string at the "=", copy what's to the left into #name, what's to the right into $value. ($name, $value) = split(/=/, $pair); #Translate all "+" into spaces in the name field. $name=~tr/+/ /; #Translate all "%##"s into the corresponding characters $name=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; #Do the same for the value field. $value=~tr/+/ /; $value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; #Finally, put the name and value into an associative array #indexed by the names of the form. $form{$name} = $value; } $rd=3.1415927/180.; $city=$form{'city'}; $month=$form{'month'}; $year=$form{'year'}; if( ($month<1 || $month>12) || ($year<=0) ) {print "ERROR: Invalid input."; print ""; print ""; exit(0); } #if($city eq 'Atlanta,GA'){$tz=-5;$lat=33.75;$long=84.38;goto skip;} #if($city eq 'Boston,MA'){$tz=-5;$lat=42.37;$long=71.05;goto skip;} #if($city eq 'Chicago,IL'){$tz=-6;$lat=41.86;$long=87.63;goto skip;} #if($city eq 'Dearborn'){$tz=-5;$lat=42.30;$long=83.23334;goto skip;} #if($city eq 'Fort Erie'){$tz=-5;$lat=42.90;$long=78.93334;goto skip;} #if($city eq 'Hamilton'){$tz=-5;$lat=43.25;$long=79.85;goto skip;} #if($city eq 'London,ON'){$tz=-5;$lat=42.98;$long=81.23;goto skip;} #if($city eq 'Montreal'){$tz=-5;$lat=45.52;$long=73.57;goto skip;} if($city eq 'New York,NY'){$tz=-5;$lat=40.75;$long=74.00;goto skip;} if($city eq 'Niagara Falls'){$tz=-5;$lat=43.10;$long=79.07;goto skip;} if($city eq 'Ottawa,ON')$tz=-5;$lat=45.43;$long=75.6833333;goto skip;} if($city eq 'Quebec'){$tz=-5;$lat=46.82;$long=71.18;goto skip;} if($city eq 'Sherbrooke'){$tz=-5;$lat=45.42;$long=71.90;goto skip;} if($city eq "Toronto,ON"){$tz=-5;$lat=43.65;$long=79.38;goto skip;} if($city eq 'Washington,DC'){$tz=-5;$lat=38.88;$long=77.00;goto skip;} if($city eq 'Windsor,ON'){$tz=-5;$lat=42.30;$long=83.02;goto skip;} if($city eq 'Vancouver,BC'){$tz=-8;$lat=49.27;$long=123.12;goto skip;} if($city eq 'Calgary,AB'){$tz=-7;$lat=51.08;$long=114.08;goto skip;} if($city eq 'Saskatoon,SK'){$tz=-7;$lat=52.12;$long=106.63;goto skip;} if($city eq 'Winnipeg,MB'){$tz=-6;$lat=49.88;$long=97.15;goto skip;} if($city eq 'Edmonton,AB'){$tz=-7;$lat=53.55;$long=113.47;goto skip;} #Europe if($city eq 'Amsterdam,Holland'){$tz=1;$lat=52.3667;$long=-4.90;goto skip;} if($city eq 'Paris,France'){$tz=1;$lat=48.8667;$long=-2.334;goto skip;} if($city eq 'London,UK'){$tz=0;$lat=51.5334;$long=-0.10;goto skip;} if($city eq 'Rome,Italy'){$tz=1;$lat=41.90;$long=-12.48334;goto skip;} if($city eq 'Frankfurt,Germany'){$tz=1;$lat=50.1;$long=-8.68334;goto skip;} if($city eq 'Athens,Greece'){$tz=2;$lat=38.00;$long=-23.70;goto skip;} if($city eq 'Milan,Italy'){$tz=1;$lat=45.46;$long=-9.20;goto skip;} #Mideast if($city eq 'Beirut,Lebanon'){$tz=2;$lat=33.8666667;$long=-35.50;goto skip;} if($city eq 'Mecca al-Mukarramah'){$tz=3;$lat=21.433333;$long=-39.8166666;goto skip;} if($city eq 'Al-Quds,Jerusalem'){$tz=2;$lat=31.78;$long=-35.21;goto skip;} if($city eq 'Madinah al-Munawwarah'){$tz=3;$lat=24.5;$long=-39.58334;goto skip;} if($city eq 'Damascus,Syria'){$tz=2 ;$lat=33.50 ;$long=-36.30 ;goto skip;} if($city eq 'Baghdad,Iraq'){$tz=3 ;$lat=33.33 ;$long=-44.40 ;goto skip;} if($city eq 'Riyadh,KSA'){$tz=3;$lat=24.65 ;$long=-46.73 ;goto skip;} if($city eq 'Kuwait,Kuwait'){$tz=3 ;$lat=29.33 ;$long=-48.00 ;goto skip;} if($city eq 'Abu Dhabi,UAE'){$tz=4 ;$lat=24.46;$long=-54.41 ;goto skip;} if($city eq 'Dubai,UAE'){$tz=4 ;$lat=25.23 ;$long=-55.28 ;goto skip;} if($city eq 'Muscat,OMAN'){$tz=4 ;$lat=23.36 ;$long=-58.61 ;goto skip;} if($city eq 'Sanaa,Yemen'){$tz=3 ;$lat=15.38 ;$long=-44.23 ;goto skip;} if($city eq 'Amman,Jordan'){$tz=2 ;$lat=31.95 ;$long=-35.93 ;goto skip;} if($city eq 'Gazza,Palestine'){$tz=2 ;$lat=31.50 ;$long=-34.46 ;goto skip;} if($city eq 'Qatif,KSA'){$tz=3 ;$lat=26.60 ;$long=-50.00 ;goto skip;} if($city eq 'Abu Dhabi,UAE'){$tz=4 ;$lat=24.46 ;$long=-54.41 ;goto skip;} #Central and South America if($city eq 'GUADALAJARA,Mexico'){$tz=-6 ;$lat=20.66 ;$long=103.33 ;goto skip;} if($city eq 'GUATEMALA,Guatemala'){$tz=-6 ;$lat=14.63 ;$long=90.36 ;goto skip;} if($city eq 'Honolulu, Hawaii'){$tz=-10 ;$lat=21.3 ;$long=157.87 ;goto skip;} if($city eq 'GEORGETOWN,Guyana'){$tz=-3.75 ;$lat=6.76 ;$long=58.16 ;goto skip;} if($city eq 'KINGSTON,Jamaica'){$tz=-5 ;$lat=17.58 ;$long=76.48 ;goto skip;} if($city eq 'MEXICO CITY,Mexico'){$tz=-6 ;$lat=19.41 ;$long=99.16 ;goto skip;} if($city eq 'MONTEVIDEO,Uruguay'){$tz=-3 ;$lat=-34.91 ;$long=56.16 ;goto skip;} if($city eq 'PANAMA,Panama'){$tz=-5 ;$lat=8.95 ;$long=79.5 ;goto skip;} if($city eq 'PARAMARIBO,Surinam'){$tz=-3.5 ;$lat=5.86 ;$long=55.23 ;goto skip;} if($city eq 'PORT OF SPAIN,Trinidad'){$tz=-4 ;$lat=10.63 ;$long=61.51;goto skip;} if($city eq 'PORT-AU-PRINCE,Haiti'){$tz=-5 ;$lat=18.55;$long=72.33 ;goto skip;} if($city eq 'QUITO,Ecuador'){$tz=-5 ;$lat=-0.23 ;$long=78.5 ;goto skip;} if($city eq 'RIO DE JANEIRO,Brasil'){$tz=-3 ;$lat=-22.88 ;$long=43.28 ;goto skip;} if($city eq 'SANTIAGO,Chile'){$tz=-4 ;$lat=-33.5 ;$long=70.66 ;goto skip;} if($city eq 'SAN SALVADOR,Salvador'){$tz=-6 ;$lat=13.66 ;$long=89.16 ;goto skip;} if($city eq 'SAN JOSE,Costa Rica'){$tz=-6 ;$lat=9.59;$long=84.04 ;goto skip;} if($city eq 'SAN JUAN,Puerto Rico'){$tz=-6 ;$lat=18.48 ;$long=66.13 ;goto skip;} if($city eq 'SANTO DOMINGO,Dominican'){$tz=-5 ;$lat=18.5 ;$long=69.95 ;goto skip;} if($city eq 'TEGUCIGALPA,Honduras'){$tz=-6 ;$lat=14.08 ;$long=87.23 ;goto skip;} if($city eq 'MANAGUA,Nicaragua'){$tz=-6 ;$lat=12.16 ;$long=86.3 ;goto skip;} if($city eq 'LIMA,Peru'){$tz=-5 ;$lat=-12.1 ;$long= 77.05 ;goto skip;} if($city eq 'CARACAS,Venzuela'){$tz=-4 ;$lat=10.58 ;$long=66.93 ;goto skip;} if($city eq 'BUENOS AIRES,Argentina'){$tz=-3 ;$lat=-34.66 ;$long=58.5 ;goto skip;} if($city eq 'BRASILIA,Brazil '){$tz=-3 ;$lat=-15.75 ;$long=47.95 ;goto skip;} if($city eq 'BELIZE CITY,Belize'){$tz=-6 ;$lat=17.48 ;$long=88.16 ;goto skip;} if($city eq 'CAYENNE,French Guiana'){$tz=-4 ;$lat=4.91 ;$long=52.3 ;goto skip;} if($city eq 'ASUNCION,Paraguay'){$tz=-4 ;$lat=-25.25 ;$long=57.66 ;goto skip;} # #Africa if($city eq 'Cairo,Egypt'){$tz=2;$lat=30.05 ;$long=-31.25 ;goto skip;} if($city eq 'Alger,Algeria'){$tz=1 ;$lat=36.83;$long=-3.00;goto skip;} if($city eq 'Tripoli,Lybia'){$tz=1;$lat=32.90;$long=-13.18;goto skip;} if($city eq 'Tunis,Tunisia'){$tz=1;$lat=36.83;$long=-10.21;goto skip;} if($city eq 'Rabat,Morroco'){$tz=0 ;$lat=34.03;$long=6.85 ;goto skip;} if($city eq 'Khartoum,Sudan'){$tz=2;$lat=15.55;$long=-32.58;goto skip;} if($city eq 'Ismailiyah,Egypt'){$tz=2;$lat=30.60;$long=-32.25;goto skip;} if($city eq 'Iskandariyah,Egypt'){$tz=2;$lat=31.21;$long=-29.91;goto skip;} if($city eq 'Abidjan,Ivory Coast'){$tz=0 ;$lat=5.31;$long=4.01;goto skip;} if($city eq 'Abuja,Nigeria'){$tz=1 ;$lat=9.16;$long=-7.18;goto skip;} if($city eq 'Accra,Ghana'){$tz=0 ;$lat=5.55 ;$long=0.25 ;goto skip;} if($city eq 'Nairobi,Kenya'){$tz=3 ;$lat=-11.11;$long=-36.83;goto skip;} if($city eq 'Adis Abeba,Ethipia'){$tz=3;$lat=9.05;$long=-38.70;goto skip;} if($city eq 'Agadir,Morroco'){$tz=0 ;$lat=30.50;$long=9.66;goto skip;} if($city eq 'Al-Obeid,Sudan'){$tz=2 ;$lat=13.18 ;$long=-30.16;goto skip;} if($city eq 'Antananarivo,Madagascar'){$tz=3;$lat=-18.86;$long=-47.50;goto skip;} if($city eq 'Asmera,Eriteria'){$tz=3 ;$lat=15.33;$long=-38.96;goto skip;} if($city eq 'Aswan,Egypt'){$tz=2 ;$lat=24.05 ;$long=-32.56;goto skip;} if($city eq 'Asyut,Egypt'){$tz=2 ;$lat=27.23 ;$long=-31.11;goto skip;} if($city eq 'Johannesburg,South Africa'){$tz=2 ;$lat=-26.16;$long=7.98;goto skip;} if($city eq 'Bamako,Mali'){$tz=0 ;$lat=12.66 ;$long=7.98;goto skip;} if($city eq 'Cape town,South Africa'){$tz=2 ;$lat=-33.93;$long=-18.46;goto skip;} if($city eq 'Nairobi,Kenya'){$tz=3;$lat=-11.11;$long=-36.83;goto skip;} if($city eq 'Dakar,Senegal'){$tz=0 ;$lat=14.63;$long=17.45;goto skip;} if($city eq 'Daressalam,Tanzania'){$tz=3;$lat=-6.85;$long=-39.30;goto skip;} #Asia if($city eq 'ISLAMABAD,Pakistan'){$tz=5;$lat=33.66;$long=-73.73;goto skip;} if($city eq 'KABUL,Afghanistan'){$tz=4.5;$lat=34.51;$long=-69.20;goto skip;} if($city eq 'KARACHI,Pakistan'){$tz=5;$lat=24.85;$long=-67.03;goto skip;} if($city eq 'LAHORE,Pakistan'){$tz=5 ;$lat=31.58 ;$long=-74.36;goto skip;} if($city eq 'AMRITSAR,India'){$tz=5.5 ;$lat= 31.58 ;$long=-74.95;goto skip;} if($city eq 'ASHKABAD,Turkmenistan'){$tz= 5;$lat=37.96;$long=-58.40;goto skip;} if($city eq 'BANDUNG,Indonesia'){$tz=7;$lat=-6.95 ;$long=-107.56;goto skip;} if($city eq 'BANGALORE, India'){$tz=5.5 ;$lat=12.96 ;$long=-77.58 ;goto skip;} if($city eq 'BANGKOK,Thailand '){$tz=6.5 ;$lat=13.73 ;$long=-100.51 ;goto skip;} if($city eq 'BEIJING,China'){$tz= 8 ;$lat=39.91 ;$long=-116.41 ;goto skip;} if($city eq 'BENDAR SERIBEGAWAN,Brunei '){$tz= 8 ;$lat=4.93 ;$long=-114.96;goto skip;} if($city eq 'Bumbai,India'){$tz=5.5 ;$lat=18.93 ;$long=-72.85 ;goto skip;} if($city eq 'BUKHARA,Uzbekistan'){$tz=5 ;$lat=39.78 ;$long=-64.45;goto skip;} if($city eq 'MANILA,Philipines'){$tz=8 ;$lat=14.60 ;$long=-120.98;goto skip;} if($city eq 'MALE,Maldives'){$tz=5 ;$lat=4.00 ;$long=-73.46 ;goto skip;} if($city eq 'DHAKA,Bangladesh'){$tz=6 ;$lat=23.70 ;$long=-90.31 ;goto skip;} if($city eq 'DUSHANBE,Tajikstan'){$tz=5 ;$lat= 38.63 ;$long=-68.85;goto skip;} if($city eq 'HANOI,Vietnam'){$tz=7 ;$lat=21.01 ;$long=-105.86 ;goto skip;} if($city eq 'JAKARTA,Indonesia'){$tz=7 ;$lat=-6.13 ;$long=-106.75;goto skip;} if($city eq 'HERAT,Afghanistan'){$tz=4.5 ;$lat=34.33 ;$long=-62.20;goto skip;} if($city eq 'HOCHIMINH,Vietnam '){$tz=7 ;$lat=10.76 ;$long=-106.71;goto skip;} if($city eq 'HYDERABAD, India'){$tz=5.5 ;$lat=17.36 ;$long=-78.43 ;goto skip;} if($city eq 'KARACHI,Pakistan'){$tz=5 ;$lat=24.85 ;$long=-67.03 ;goto skip;} if($city eq 'KATMANDU,Nepal'){$tz=5.5 ;$lat=27.70 ;$long=-85.31 ;goto skip;} if($city eq 'KOWLOON,Hong Kong'){$tz=8 ;$lat= 22.31 ;$long=-114.20 ;goto skip;} if($city eq 'KUALA LAMPUR,Malaysia'){$tz=8 ;$lat=3.13 ;$long=-101.70 ;goto skip;} if($city eq 'MAZARISHARIF,Afghanistan'){$tz=4.5 ;$lat=36.70 ;$long=-67.10 ;goto skip;} if($city eq 'MEDAN,Indonesia'){$tz=7 ;$lat=3.58 ;$long=-98.65 ;goto skip;} if($city eq 'PYONGYANG,North Korea'){$tz=9 ;$lat=39.00 ;$long=-125.78 ;goto skip;} if($city eq 'QANDAHAR,Afghanistan'){$tz=4.5 ;$lat=31.58 ;$long=-65.75 ;goto skip;} if($city eq 'RANGOON,Burma'){$tz=6.5;$lat=16.78;$long=-96.16;goto skip;} if($city eq 'SABAH,Malaysia'){$tz=8;$lat=5;$long=-117.5;goto skip;} if($city eq 'SAMARINDA,Indonesia'){$tz=7;$lat=-0.30;$long=-117.09;goto skip;} if($city eq 'SAMARKAND, Uzbekistan'){$tz=5;$lat=39.40;$long=-66.57;goto skip;} if($city eq 'SEOUL,South Korea'){$tz=9;$lat=37.50;$long=-127.00;goto skip;} if($city eq 'SINGAPORE,Singapore'){$tz=7;$lat=1.28;$long=-103.85;goto skip;} if($city eq 'SURABAYA,Indonesia'){$tz=7;$lat=-7.23 ;$long=-112.75;goto skip;} if($city eq 'TAIPEI,Taiwan'){$tz=8;$lat=25.08;$long=-121.50;goto skip;} if($city eq 'TASHKAENT,Kirgizia'){$tz=6;$lat=41.26;$long=-69.21;goto skip;} if($city eq 'THIMBU,Bhutan'){$tz=5.5;$lat=27.46 ;$long=-89.65 ;goto skip;} if($city eq 'TOKYO,Japan'){$tz=5.5 ;$lat=27.46 ;$long=-89.65 ;goto skip;} if($city eq 'VIENTIANE, Laos'){$tz=7 ;$lat=17.98 ;$long=-102.63;goto skip;} # #ocenia if($city eq 'ADELAIDE,Australia'){$tz=9.5;$lat=-34.93;$long=-138.60;goto skip;} if($city eq 'APIA,Western Samoa'){$tz=11;$lat=-3.80 ;$long=171.75;goto skip;} if($city eq 'AUCKLAND,New Zealand'){$tz=12;$lat=-36.86 ;$long=-174.75;goto skip;} if($city eq 'BRISBANE,Australia'){$tz=10;$lat=-27.50;$long=-153.00;goto skip;} if($city eq 'CANBERRA, Australia'){$tz=10;$lat=-35.30;$long=-149.13;goto skip;} if($city eq 'SYDNEY,Australia'){$tz=10;$lat=-33.88;$long=-151.16;goto skip;} if($city eq 'WELLINGTON,New Zealand'){$tz=12;$lat=-41.28;$long=-174.78;goto skip;} if($city eq 'PERTH,Australia'){$tz=8;$lat=-31.96;$long=-115.86;goto skip;} if($city eq 'DUNEDIN,New Zealand'){$tz=12 ;$lat=-45.86 ;$long=-170.50 ;goto skip;} if($city eq 'FUNAFUTI,Tuvalu'){$tz=12 ;$lat=-8.50 ;$long=-179.20 ;goto skip;} if($city eq 'HONIARA,Solomon Islands'){$tz=11 ;$lat=-9.46 ;$long=-159.95 ;goto skip;} if($city eq 'MELBOURNE,Australia'){$tz=10 ;$lat=-37.75 ;$long=-144.96 ;goto skip;} if($city eq 'NUKU ALOFA,Tonga'){$tz=13;$lat=-21.15 ;$long=175.23;goto skip;} if($city eq 'PORT MORESBY,New Guinea'){$tz=10;$lat=-9.50;$long=-147.11 ;goto skip;} if($city eq 'PORT VILA,Vanuata'){$tz=11;$lat=-17.75;$long=-168.31;goto skip;} if($city eq 'SUVA,Fiji'){$tz=12;$lat=-18.13;$long=-178.41;goto skip;} if($city eq 'TARAWA,Kiribati'){$tz=12;$lat= 1.50;$long=-173.00;goto skip;} #..........skip skip: ; if( (!$city) || (!$lat) || (!$tz) || (!$long) ) {print "ERROR: Invalid input, please re-try."; print ""; print ""; exit(0); } @months=("January", "February", "March", "April", "May", "June", "July", "August","September", "October", "November", "December"); if($month==1 || $month==3 || $month==5 || $month==7 || $month==8 || $month==10 || $month==12) { $j=31; } else { $j=30; } print "
", $city," Prayer Times "; print "
"; print @months[$month-1]," ",$form{'year'}; print "
"; print "Latitude=",$lat; if($lat >0.){ print "N";} if($lat <0.){ print "S";} print " Longitude=",$long; if($long >0.){ print "W";} if($long <0.){ print "E";} print " Time Zone=",$tz; print "

"; print "
"; print ""; print ""; print ""; print ""; #Subroutine Julian ************************ sub julian() { $dy=$_[0]; $m=$_[1]; $yr=$_[2]; if ($m <=2 ) {--$yr; $m+=12;} $a=int(($yr) /100.) ; if( $yr < 1582 ) { $b=0;} if( $yr==1582 && $m<=10 && $dy<15) {$b=0;} else { $b=2.-$a+int($a/4);} $jd=int( 365.25*($yr +4716.)) + int(30.6001*($m +1.))+$dy+$b-1524.5; #print "\n ",$jd, " days "; return($jd); } # end julian ******** # # sub hour() { $dec=$_[0]; $lat=$_[1]; $H=(acos( (-tan($rd*$lat) )*tan($dec*$rd) ) )/(15.*$rd); return($H); } sub lst2gst() { $LST=$_[0]; $LONG=$_[1]; $LONG/=15.; $GST=$LST+$LONG; while($GST>24.) {$GST-=24.; } while($GST<0.) {$GST+=24.; } return($GST); } # end subroutine lst2gst ******************* # Sub gst2ut sub gst2ut { $jd = $_[0]; $gst = $_[1]; $s=&julian($day, $month, $year)-2451545.; $T=$s/36525.; $T0=6.697374558+2400.051336*$T+0.000025862*$T*$T; $gst-=$T0; while($gst<0.) {$gst+=24.; } while($gst>24.) {$gst-=24.; } $ut=$gst*0.9972695663; return($ut); } #end sub gst2ut************************* # if($month==2){ if( $year%4==0.) { $j=29; if($year%100==0. ){$j=29}; } else {$j=28;} } ###################################### for($i=1;$i<=$j;++$i){ $day=$i; $d=&julian($day,$month,$year); $dd=$d-&julian(0., 1.,1990); $T=(&julian($day,$month,$year)-2451545.)/36525.; $e=23.439292-(46.815*$T+.0006*$T*$T-.00181*$T*$T*$T)/3600.; $n=(360.0*$dd)/365.242191; while($n<0) { $n +=360. }; if($n>360.) { $n -=360. }; $M0=$n+279.403303-282.768422; if($M0<0) { while($M0<0) { $M0 +=360. }; }; $Ec=(360./3.1415927)*0.016713*sin($M0*3.1415927/180.); $L0=$n+$Ec+279.403303; while($L0>360.0) { $L0 -=360. }; #printf("%f\n", $L0); # # Remember that Beta0 for Sun =0, now get dec and Ra method 27... $rd=3.1415927/180.0; $L0*=$rd; $e*=$rd; $l=asin((sin($e))*(sin($L0))); $l/=$rd; $y=(sin($L0))*(cos($e)); $x=cos($L0); $a=(atan($y/$x))/$rd; # corrections for quadrants if($y<0 && $x>0) { $a+=360.; }; if($y<0 && $x<0) { $a+=180.; }; if($y>0 && $x<0) { $a+=180.; }; $a /=15.; $dec1=$l; $ra1=$a; if($ra1>24.){$ra1-=24.;}; #printf("%15.7f\n", $ra1); #printf("%15.7f\n", $dec1); # # 24 hours later # $L0+=0.985647*$rd; $l=asin((sin($e))*(sin($L0))); $l/=$rd; $y=(sin($L0))*(cos($e)); $x=cos($L0); $a=(atan($y/$x))/$rd; # corrections for quadrants if($y<0 && $x>0) { $a+=360.; }; if($y<0 && $x<0) { $a+=180.; }; if($y>0 && $x<0) { $a+=180.; }; $a /=15.; $dec2=$l; $ra2=$a; if($ra2>24.){$ra2-=24.;}; #printf("%15.7f\n", $ra2); #printf("%15.7f\n", $dec2); $H=(-tan($lat*$rd))*tan($dec1*$rd); $H=acos($H); $H/=15.*$rd; while($H <0.) { $H+= 24. }; while($H>24.) { $H -=24. }; #&hour($dec1,$lat,0.); $LSTRr1=24.+$ra1-$H; while($LSTRr1>24.){$LSTRr1-=24.}; $LSTRs1=$ra1+$H; while($LSTRs1>24.){$LSTRs1-=24.}; #printf("%15.7f\n", $LSTRr1); #printf("%15.7f\n", $LSTRs1); $HR=(-tan($lat*$rd))*(tan($dec2*$rd)); $HR=acos($HR); $HR/=15.*$rd; while($HR<0) { $HR +=24. }; while($HR>24.) { $HR -=24. }; #$H=&hour($dec2,$lat,0.); $LSTRr2=24+$ra2-$HR; while($LSTRr2>24.){$LSTRr2-=24.}; $LSTRs2=$ra2+$HR; while($LSTRs2>24.){$LSTRs2-=24.}; #printf("%15.7f\n", $LSTRr2); #printf("%15.7f\n", $LSTRs2); # convert lst to gst # $gst1r=&lst2gst($LSTRr1,$long); $gst1s=&lst2gst($LSTRs1,$long); $gst2r=&lst2gst($LSTRr2,$long); $gst2s=&lst2gst($LSTRs2,$long); if($gst1r>$gst2r) {$gst2r+=24.;} if($gst1s>$gst2s) {$gst2s+=24.;} #printf("%15.7f\n", $gst1r); #printf("%15.7f\n", $gst1s); #printf("%15.7f\n", $gst2r); #printf("%15.7f\n", $gst2s); #find T00 $s=&julian($day, $month, $year)-2451545.; $T=$s/36525.; $T0=6.697374558+2400.051336*$T+0.000025862*$T*$T; while($T0<0.) {$T0+=24.; } while($T0>24.) {$T0-=24.; } # printf("%15.7f\n", $T0); # calculate the GST at 0h on the observer's longitude... $T01=$T0+($long/15.)*1.002738; #$T01=$T0-$tz*1.002738; #printf("%15.7f\n", $T01); if($T01<0.) {$T01+=24.;} if($gst1r<$T01) {$gst1r+=24.; $gst2r+=24.;} if($gst1s<$T01) {$gst1s+=24.; $gst2s+=24.;} $gstr=(24.07*$gst1r-$T01*($gst2r-$gst1r))/(24.07+$gst1r-$gst2r); $gsts=(24.07*$gst1s-$T01*($gst2s-$gst1s))/(24.07+$gst1s-$gst2s); #calculate the correction dt $dec=.5*($dec1+$dec2); $psi=acos( sin($rd*$lat) / cos($rd*$dec) ); #diff due to refraction.. #$H=&hour($dec, $lat); #$H=103.282682; #$H*=15.; #$DH=34./(15.*(cos($lat*$rd))*(cos($dec*$rd))*(sin($H*$rd)) ); #$DH/=60.; #$x=0.830725; $x = 0.8; # $dA=asin( (tan($rd*$x))/tan($psi)); # $dA/=$rd; # $Ar-=$dA; #$ As+=$dA; $y=asin( sin($rd*$x) / sin($psi) ); $y/=$rd; $dt=(240.*$y)/(cos($rd*$dec)); $dt/=3600.; $gstr-=$dt; $gsts+=$dt; $jd=&julian($day,$month,$year); $uts=&gst2ut($jd,$gsts); $utr=&gst2ut($jd,$gstr); $utr+=$tz; $uts+=$tz; if($uts>24.){$uts-=24;} if($utr>24.){$utr-=24;} $noon=$utr+($uts-$utr)/2.; $asr=$noon+ 4.*(abs($uts-$noon))/7.; if($asr>12.){$asr-=12.}; if($uts>12.) { $uts-=12.; } $magrib=$uts+.25; # lat is less than 48.5 if( abs( $lat) <=48.5){ $E=12.-$noon+($long)/15.; # #$E/=60.; # #print(" lat long="); #printf("%f %f \n", $lat, $long); #$hi=&hour($dec,$lat,-18.); $hi=(sin(-18.*$rd)-(sin($lat*$rd))*sin($dec*$rd))/((cos($lat*$rd))*cos($dec*$rd)); $hi=acos($hi); $hi/=$rd*15.; $imsak=12.-$hi-$E+$long/15.; } # bet 48.5 and 51.5 if( (abs( $lat) <= 54.56) && ((abs($lat) > 48.5)) ){ $ aa = -( 90. - ($lat +23.44)); $H=(sin($aa * $rd)-(sin($lat*$rd))*sin($dec*$rd))/((cos($lat*$rd))*cos($dec*$rd)); $H=acos($H); $H/=$rd*15.; $imsak=12.-$H-$E+($long)/15.; } if($imsak<0.){$imsak+=12.;} $fajr=$imsak+2./6.; if( (abs( $lat) <=35.) ){ $H=(sin(-15 * $rd)-(sin($lat*$rd))*sin($dec*$rd))/((cos($lat*$rd))*cos($dec*$rd)); $H=acos($H); $H/=$rd*15.; $fajr=12.-$H-$E+($long)/15.; } $isha=$hi-$E+($long)/15.; if(($tz==-5 || $tz==-6) && (($month>4 && $month<11)||($month==4 && $i>=7))) {$imsak++; $fajr++; $utr++; $noon++; $uts++; $magrib++; $isha++; } if($noon>13.) { $noon-=12.; } if($noon>12.) {$asr+=$noon-12.;} else { $asr+=$noon;} if($utr<0.) { $utr+=12.; } if($uts<0.) { $uts+=12.; } if($asr<0.) { $asr+=12.; } if($magrib<0.) { $magrib+=12.; } if($isha<0.) { $isha+=12.; } if($i<10) {$I=$i/100.; print ""; print ""; print "
"; print "Day"; print ""; print "Imsak"; print ""; print " Fajr "; print ""; print "Sunrise"; print ""; print " Noon "; print ""; print " Asr "; print ""; print "Sunset"; print ""; print "Magrib"; print ""; print " Isha "; print "
"; print substr($I,2,4); } else { print "
"; print $i; } print "
"; if(.6*($imsak-int($imsak))>=.595) { printf("%8.2f ",int($imsak)+1);} else { printf("%8.2f ",int($imsak)+.6*($imsak-int($imsak)));} print "
"; if(.6*($fajr-int($fajr))>=.595) { printf("%8.2f ",int($fajr)+1);} else { printf("%8.2f ",int($fajr)+.6*($fajr-int($fajr)));} print "
"; if(.6*($utr-int($utr))>=.595) { printf("%8.2f ",int($utr)+1);} else { printf("%8.2f ",int($utr)+.6*($utr-int($utr)));} print "
"; if((.6*($noon-int($noon))>=.595) ) { if($noon>12.){$noon-=12.;} printf("%8.2f ",int($noon)+1); } else {printf("%8.2f ",int($noon)+.6*($noon-int($noon)));} print "
"; if(.6*($asr-int($asr))>=.595) { printf("%8.2f ",int($asr)+1); } else { printf("%8.2f ",int($asr)+.6*($asr-int($asr)));} print "
"; if(.6*($uts-int($uts))>=.595) { printf("%8.2f ",int($uts)+1); } else { printf("%8.2f ",int($uts)+.6*($uts-int($uts)));} print "
"; if(.6*($magrib-int($magrib))>=.595) { printf("%8.2f ",int($magrib)+1); } else { printf("%8.2f ",int($magrib)+.6*($magrib-int($magrib)));} print "
"; if(.6*($isha-int($isha))>=.595) { printf("%8.2f ",int($isha)+1); } else { printf("%8.2f ",int($isha)+.6*($isha-int($isha)));} } #end loop print "
"; print ""; print "";