916 if (abs($this->_unixTimestamp) <= 0x7FFFFFFF) {
917 if ($rise ===
false) {
918 return date_sunset($this->_unixTimestamp, SUNFUNCS_RET_TIMESTAMP, $location[
'latitude'],
919 $location[
'longitude'], 90 + $horizon, $this->
getGmtOffset() / 3600);
921 return date_sunrise($this->_unixTimestamp, SUNFUNCS_RET_TIMESTAMP, $location[
'latitude'],
922 $location[
'longitude'], 90 + $horizon, $this->
getGmtOffset() / 3600);
927 $quarterCircle = 0.5 * M_PI;
929 $threeQuarterCircle = 1.5 * M_PI;
930 $fullCircle = 2 * M_PI;
933 $radLatitude = $location[
'latitude'] * $halfCircle / 180;
934 $radLongitude = $location[
'longitude'] * $halfCircle / 180;
937 $tmpRise = $rise ? $quarterCircle : $threeQuarterCircle;
938 $radDay = $this->
date(
'z',$this->_unixTimestamp) + ($tmpRise - $radLongitude) / $fullCircle;
941 $solAnomoly = $radDay * 0.017202 - 0.0574039;
942 $solLongitude = $solAnomoly + 0.0334405 * sin($solAnomoly);
943 $solLongitude += 4.93289 + 3.49066E-4 * sin(2 * $solAnomoly);
946 $solLongitude = $this->_range($solLongitude, $fullCircle);
948 if (($solLongitude / $quarterCircle) - intval($solLongitude / $quarterCircle) == 0) {
949 $solLongitude += 4.84814E-6;
953 $solAscension = sin($solLongitude) / cos($solLongitude);
954 $solAscension = atan2(0.91746 * $solAscension, 1);
957 if ($solLongitude > $threeQuarterCircle) {
958 $solAscension += $fullCircle;
959 }
else if ($solLongitude > $quarterCircle) {
960 $solAscension += $halfCircle;
964 $solDeclination = 0.39782 * sin($solLongitude);
965 $solDeclination /= sqrt(-$solDeclination * $solDeclination + 1);
966 $solDeclination = atan2($solDeclination, 1);
968 $solHorizon = $horizon - sin($solDeclination) * sin($radLatitude);
969 $solHorizon /= cos($solDeclination) * cos($radLatitude);
972 if (abs($solHorizon) > 1) {
976 $solHorizon /= sqrt(-$solHorizon * $solHorizon + 1);
977 $solHorizon = $quarterCircle - atan2($solHorizon, 1);
980 $solHorizon = $fullCircle - $solHorizon;
984 $localTime = $solHorizon + $solAscension - 0.0172028 * $radDay - 1.73364;
985 $universalTime = $localTime - $radLongitude;
988 $universalTime = $this->_range($universalTime, $fullCircle);
991 $universalTime *= 24 / $fullCircle;
994 $hour = intval($universalTime);
995 $universalTime = ($universalTime - $hour) * 60;
996 $min = intval($universalTime);
997 $universalTime = ($universalTime - $min) * 60;
998 $sec = intval($universalTime);
1000 return $this->
mktime($hour, $min, $sec, $this->
date(
'm', $this->_unixTimestamp),
1001 $this->
date(
'j', $this->_unixTimestamp), $this->
date(
'Y', $this->_unixTimestamp),
date($format, $timestamp=null, $gmt=false)
mktime($hour, $minute, $second, $month, $day, $year, $gmt=false)