diff --git a/public/index.php b/public/index.php index 806799b..7bd0dd9 100644 --- a/public/index.php +++ b/public/index.php @@ -17,6 +17,20 @@ if (!function_exists('fmtLocalTime')) { if (!function_exists('azDir')) { function azDir(float $az): string { $dirs = ['N','NO','O','SO','S','SW','W','NW']; return $dirs[(int)round($az / 45) % 8]; } } +if (!function_exists('formatDurationHoursMinutes')) { + function formatDurationHoursMinutes(int $minutes): string { + $minutes = max(0, $minutes); + $hours = intdiv($minutes, 60); + $restMinutes = $minutes % 60; + if ($hours > 0 && $restMinutes > 0) { + return sprintf('%d Stunden %d Minuten', $hours, $restMinutes); + } + if ($hours > 0) { + return sprintf('%d Stunden', $hours); + } + return sprintf('%d Minuten', $restMinutes); + } +} function idx_tleChecksum(string $line): int { @@ -94,6 +108,7 @@ function buildTleLine2(array $sat, array $tle): string // Standort und astronomische Daten nur wenn eingeloggt und Standort vorhanden $skyData = null; +$skyDataNext = null; $planetData = null; $satData = null; $pyError = null; @@ -155,6 +170,26 @@ if ($loggedIn) { $raw = json_decode($rawText, true); if (is_array($raw) && ($raw['ok'] ?? false)) { $skyData = $raw; + $nextDate = (new DateTimeImmutable($date, new DateTimeZone($tz)))->modify('+1 day')->format('Y-m-d'); + $argsNext = [ + $pythonBin, + escapeshellarg($scriptPath), + escapeshellarg('sun_moon_rise_set'), + escapeshellarg((string)$lat), + escapeshellarg((string)$lon), + escapeshellarg((string)$elev), + escapeshellarg($nextDate), + escapeshellarg($tz), + ]; + $cmdNext = implode(' ', $argsNext) . ' 2>&1'; + $outNext = []; + $resultCodeNext = 0; + exec($cmdNext, $outNext, $resultCodeNext); + $rawTextNext = trim(implode("\n", $outNext)); + $rawNext = json_decode($rawTextNext, true); + if (is_array($rawNext) && ($rawNext['ok'] ?? false)) { + $skyDataNext = $rawNext; + } } else { $pyError = $raw['error'] ?? ($rawText !== '' ? $rawText : 'Fehler beim Berechnen der Aufgangszeiten.'); } @@ -272,7 +307,19 @@ if ($loggedIn) { — = h((new DateTimeImmutable('now', new DateTimeZone($tz)))->format('d.m.Y')) ?>
- + $deepSkyStart) + ? (int) floor(($deepSkyEnd->getTimestamp() - $deepSkyStart->getTimestamp()) / 60) + : null; + ?>Keine vollstaendige astronomische Nacht im berechneten Zeitraum.
+ +