suncalc-php
suncalc-php copied to clipboard
Bug in Moonphase & Moonangle
Hello gregseth!
PHP 5.6.3 (cli) (built: Nov 14 2014 20:21:33) Zend Engine v2.6.0 with Zend OPcache v7.0.4-dev
<?php
date_default_timezone_set('UTC');
include 'suncalc.php';
$timestampinput = '367930576.999999';
$datetime = new DateTime();
$datetime->setTimestamp($timestampinput);
$suncalc = new SunCalc($datetime, 0.0, 0.0);
$moonillumination = $suncalc->getMoonIllumination();
$moonfraction = $moonillumination["fraction"];
$moonphase = $moonillumination["phase"];
$moonangle = $moonillumination["angle"];
echo "Timestamp: $timestampinput";
echo "Fraction: $moonfraction";
echo "Phase: $moonphase";
echo "Angle: $moonangle";
?>
Timestamp: 367930576.999999 Fraction: 0.00055706175882264 Phase: 0.99248650278035 Angle: 3.1415787022219
Timestamp: 367930577.000000 Fraction: 0.00055704489929154 Phase: 0.0075133834992909 Angle: -3.1415560468408
There is a jump in the moon phase of 0.0150268807 and a jump in the moon angle of 6.2831347491 within a microsecond. Normally this must be several minutes difference.
Please answer.
Hi,
The PHP function setTimestamp
takes an integer, so the real difference between you two tests is one second, not one microsecond.
Plus, the angle is within ]-π; π] and the phase within [0; 1[, they're just cycling around.