<?php
/* ************************************************************************ */
function sunset_sunrise($object, $days = 7) {
$days = $days <= 30 ? $days : 30;
$start = date("d");
$start_day = date("w");
$name_day = array("Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota");
$stop = ($start + $days) < date("t") ? ($start + $days) : date("t");
$it = 0;
$return = array(array());
for($i = $start; $i < $stop; $i++) {
$return[$it]["date"] = $i . "." . date("n.Y") . " - " . $name_day[fmod($start_day++, 7)];
$return[$it]["sunrise"] = $object->rise(mktime(0, 0, 0, date("n"), $i, date("Y")));
$return[$it]["sunset"] = $object->set(mktime(0, 0, 0, date("n"), $i, date("Y")));
$it++;
}
// Next month, if needed
if($it < $days) {
$start = 1;
$stop = ($days + 1) - $it;
$month = date("n") + 1;
for($i = $start; $i < $stop; $i++) {
$return[$it]["date"] = $i . "." . $month . "." . date("Y") . " - " . $name_day[fmod($start_day++, 7)];
$return[$it]["sunrise"] = $object->rise(mktime(0, 0, 0, $month, $i, date("Y")));
$return[$it]["sunset"] = $object->set(mktime(0, 0, 0, $month, $i, date("Y")));
$it++;
}
}
return $return;
}
/* ************************************************************************ */
require_once("./sun.php");
$sun = new SUN();
$sun->set_timezone(1);
$sun->set_coords("50°7'0.64\"N 16°13'1.35\"E");
$times = sunset_sunrise($sun);
// Print result
print_r($times);
?>
|