$lat = 49.5668; // +N, -S gg.mmss
$lon = 34.5761; // +E, -W
$d=date('d',time());
$m=date('m',time());
$y=date('Y',time());
$n1=floor(275/9*$m);
$n2=floor(($m+9)/12);
$n3=1+floor(($y-4*floor($y/4)+2)/3);
$n=$n1-($n2*$n3)+$d-30;
if ($lon>=0){
$c16=floor($lon);
$c17=floor(($lon-floor($lon))*100);
$c18=($lon-$c16-$c17/100)*1000;
$vlong=$c16+($c17+$c18/10)/60;
} else{
$c16=ceil($lon);
$c17=ceil(($lon-floor($lon))*100);
}
$c18=($lon-$c16-$c17/100)*1000;
$vlong=$c16+($c17+$c18/10)/60;
if($lat>=0){
$c20=floor($lat);
$c21=floor(($lat-floor($lat))*100);
}else{
$c20=ceil($lat);
$c21=ceil(($lat-ceil($lat))*100);
}
$c22=($lat-$c20-$c21/100)*1000;
$vlat=$c20+($c21+$c22/100)/60;
$lnghrs=$vlong/15;
$tx= date('r',time()) ;
$tmp0 = mb_substr( $tx , 26, 3, "UTF-8");
$tmp0=$tmp0-floor($lnghrs);
$trise=$n+((6-$lnghrs)/24);
$tset=$n+((18-$lnghrs)/24);
$mrise=(0.9856*$trise)-3.289;
$mset=(0.9856*$tset)-3.289; # $lrise_ не совпадает !!!
$lrise_=$mrise+(1.916*sin($mrise/180*M_PI))+(0.02*sin($mrise/180*M_PI))+282.634;
$lrise= $lrise_-360* floor($lrise_/360);
$lset_=$mset+(1.916*sin($mset/180*M_PI))+(0.02*sin($mset/180*M_PI))+282.634;
$lset= $lset_-360* floor($lset_/360);
$rarise=atan(0.91764*tan($lrise/180*M_PI))*180/M_PI;
$lqr=90*floor($lrise/90);
$rqr=90*floor($rarise/90);
$rar=($rarise+($lqr-$rqr))/15;
$raset=atan(0.91764*tan($lset/180*M_PI))*180/M_PI;
$lqs=90*floor($lset/90);
$rqs=90*floor($raset/90);
$ras=($raset+($lqs-$rqs))/15;
$sindecriser=0.39782*sin($lrise/180*M_PI);
$cosdecriser=cos(asin($sindecriser));
$sindecrises=0.39782*sin($lset/180*M_PI);
$cosdecrises=cos(asin($sindecrises));
$coshrise=(cos(90.8333/180*M_PI)-$sindecriser*sin($vlat/180*M_PI))/($cosdecriser*cos($vlat/180*M_PI));
$coshset=(cos(90.8333/180*M_PI)-$sindecrises*sin($vlat/180*M_PI))/($cosdecrises*cos($vlat/180*M_PI));
$hrise = (360-acos($coshrise)*180/M_PI)/15;
$hset= (acos($coshrise)*180/M_PI)/15;
$trise = $hrise+$rar-(0.06571*$trise)-6.622;
$tset= $hset+$ras-(0.06571*$tset)-6.622;
if(($trise-$lnghrs)<0) {
$utrise=$trise-$lnghrs+24;
}else{
if(($trise-$lnghrs)>=24){
$utrise=$trise-$lnghrs-24;
}
else{
$utrise=$trise-$lnghrs;
}
}
if(($tset-$lnghrs)<0){
$utset=$tset-$lnghrs+24*ceil(abs(($tset-$lnghrs)/24));
} else{
if(($tset-$lnghrs)>=24){
$utset= $tset-$lnghrs-24;
} else{
$utset=$tset-$lnghrs;
}
}
$utcrise=floor($utrise)*60+floor(($utrise-floor($utrise))*60);
$utcHrise= floor($utcrise/60);
$utcMrise= floor($utcrise-$utcHrise*60);
$loctimerise= floor($utrise)*60+floor(($utrise-floor($utrise))*60)+floor($lnghrs)*60;
$locHrise= floor($loctimerise/60);
$locMrise= floor($loctimerise-$locHrise*60);
$st2=$locMrise;
if ($st2<10){
$st2=("0".$st2);
}
$st1=($locHrise+$tmp0)%24;
if ($st1<10){
$st1=("0".$st1);
}
$st=($st1.":".$st2);
SetGlobal('ThisComputer.SunRiseTime',$st);
$str=$st;
$utcset=floor($utset)*60+floor(($utset-floor($utset))*60);
$utcHset= floor($utcset/60);
$utcMset= floor($utcset-$utcset*60);
$loctimeset= floor($utset)*60+floor(($utset-floor($utset))*60)+floor($lnghrs)*60;
$locHset= floor($loctimeset/60);
$locMset= floor($loctimeset-$locHset*60);
$st=($locHset.":".$locMset);
$st2=$locMset;
if ($st2<10){
$st2=("0".$st2);
}
$st1=($locHset+$tmp0)%24;
if ($st1<10){
$st1=("0".$st1);
}
$st=($st1.":".$st2);
SetGlobal('ThisComputer.SunSetTime',$st);
echo gg('ThisComputer.SunRiseTime').";".gg('ThisComputer.SunSetTime');
Debmes(gg('ThisComputer.SunRiseTime').";".gg('ThisComputer.SunSetTime'));