@ 2014-08-11T22:06:48Z <?php
/**
results in hhvm differ from php's
**/
function main($year, $limit)
{
$PERIOD = 0.080905722906849315068493150684932;
$PERIOD_HALF = 0.040452861453424657534246575342;
//printf("PERIOD : %.33f\n", $PERIOD);
//printf("PERIOD_HALF: %.33f\n", $PERIOD_HALF);
$old = 0;
do {
$year += $PERIOD;
$jde = calc($year, 0.0);
if ($old != 0) {
$diff = $jde - $old;
if ($diff > 40) {
$year2 = $year - $PERIOD_HALF;
$jde2 = calc($year2, 0.0);
$jde2 = calc($year2, 0.5);
}
}
$jde = calc($year, 0.5);
$old = $jde;
} while ($year <= $limit);
}
function calc($year, $phase)
{
$k = floor(($year - 2000) * 12.3685);
$k += $phase;
$T = $k / 1236.85;
$jde = 2451550.09766 + 29.530588861 * $k
+ (0.00015437 + (-0.000000150 + 0.00000000073 * $T) * $T) * $T * $T;
//Print by changing %.12f from %.1f ~ %12.f or more
//It's not the problem of printf/sprintf. But it's much more about arithmetic calculation.
printf("%.10f %.1f %.1f\n", $jde, $k, $phase);
}
/**********************************************/
if (count($argv) != 3) {
print "
start_year and end_year could be any calendar year
Usage: php $argv[0] start_year end_year
ex : php $argv[0] 2014 2030
";
exit;
}
$year = $argv[1];
$limit = $argv[2];
if($year > $limit) {
print "
end_year($limit) must be greater than or equal to start_year($year)
";
exit;
}
if($year < -13000 || $limit > 17000) {
print "
Range: -13000 ~ 17000
";
exit;
}
main($year, $limit);
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 4.3.2 - 4.3.11 , 4.4.0 - 4.4.9 , 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.10 , 7.2.0 - 7.2.33 , 7.3.16 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.27 , 8.2.0 - 8.2.17 , 8.3.0 - 8.3.4 start_year and end_year could be any calendar year
Usage: php /in/e9jm1 start_year end_year
ex : php /in/e9jm1 2014 2030
Output for 4.3.0 - 4.3.1 Notice: Undefined variable: argv in /in/e9jm1 on line 50
Notice: Undefined variable: argv in /in/e9jm1 on line 54
Notice: Undefined variable: argv in /in/e9jm1 on line 55
start_year and end_year could be any calendar year
Usage: php start_year end_year
ex : php 2014 2030
preferences:dark mode live preview
238.9 ms | 401 KiB | 350 Q