<?php

require '../app.inc.php';
require '../appmenu.inc.php';

$app = new Application('Sonnenaufgang und -untergang', $menu);
$app->header();

require_once 'sunrise.inc.php';

$suncalc = new Astro_Sunrise();
if (!empty($_GET['lat']) && !empty($_GET['lon']))
  $suncalc->setCoords($_GET['lat'], $_GET['lon']);
if (!empty($_GET['tz']))
  $suncalc->setTimezone($_GET['tz']);
if (!empty($_GET['year']) && !empty($_GET['month']) && !empty($_GET['mday']))
  $suncalc->setDate($_GET['year'], $_GET['month'], $_GET['mday']);
else
  $suncalc->setTimestamp(time());
?>

<h2><?php echo $suncalc->getDate() ?> bei <?php echo $suncalc->getCoords() ?>, <?php echo $suncalc->getTimezone() ?></h2>

<!-- pre><?php echo print_r($suncalc, true) ?></pre -->

<p>Sonnenaufgang um <?php echo $suncalc->getSunrise() ?>, <?php echo $suncalc->getLastSwatchBeat() ?></p>
<p>Sonnenuntergang um <?php echo $suncalc->getSunset() ?>, <?php echo $suncalc->getLastSwatchBeat() ?></p>

<h3>Neue Berechnung</h3>

<form class="multifield" action=""><p>

<label for="lat">Geographische Breite (-90..90)</label>
<input type="text" id="lat" name="lat" size="5" value="<?php echo $lat ?>" /><br />
<label for="lon">Geographische Länge (-180..180)</label>
<input type="text" id="lon" name="lon" size="5" value="<?php echo $lon ?>" /><br />

<label for="tz">Zeitzone (-12..12 Stunden)</label>
<input type="text" id="tz" name="tz" size="4" value="<?php echo $tz ?>" /><br />

<label for="year">Datum</label>
<input type="text" id="year" name="year" size="4" value="<?php echo $year ?>" title="Jahr" />
<input type="text" id="month" name="month" size="2" value="<?php echo $month ?>" title="Monat (1..12)" />
<input type="text" id="mday" name="mday" size="2" value="<?php echo $mday ?>" title="Tag (1..31)" />
<br />
<input type="submit" value="Berechnen!" />

</p></form>

<?php $app->footer() ?>