Verbessere Sichtbarkeitsfarben der Planeten auf der Startseite
This commit is contained in:
+20
-2
@@ -106,18 +106,23 @@ if (!function_exists('planetVisibilityClass')) {
|
||||
|
||||
$astroDusk = eventDateTime($ev['astro_dusk'] ?? []);
|
||||
$astroDawnNext = eventDateTime($evNext['astro_dawn'] ?? []);
|
||||
$nauticalDusk = eventDateTime($ev['nautical_dusk'] ?? []);
|
||||
$civilDusk = eventDateTime($ev['civil_dusk'] ?? []);
|
||||
$nauticalDawnNext = eventDateTime($evNext['nautical_dawn'] ?? []);
|
||||
$civilDawnNext = eventDateTime($evNext['civil_dawn'] ?? []);
|
||||
|
||||
$nightSeconds = 0;
|
||||
$nauticalSeconds = 0;
|
||||
$twilightSeconds = 0;
|
||||
$visibleSeconds = 0;
|
||||
|
||||
foreach ($intervals as [$from, $to]) {
|
||||
$visibleSeconds += intervalDurationSeconds($from, $to);
|
||||
$nightSeconds += intervalOverlapSeconds($from, $to, $astroDusk, $astroDawnNext);
|
||||
$twilightSeconds += intervalOverlapSeconds($from, $to, $civilDusk, $astroDusk);
|
||||
$twilightSeconds += intervalOverlapSeconds($from, $to, $astroDawnNext, $civilDawnNext);
|
||||
$nauticalSeconds += intervalOverlapSeconds($from, $to, $nauticalDusk, $astroDusk);
|
||||
$nauticalSeconds += intervalOverlapSeconds($from, $to, $astroDawnNext, $nauticalDawnNext);
|
||||
$twilightSeconds += intervalOverlapSeconds($from, $to, $civilDusk, $nauticalDusk);
|
||||
$twilightSeconds += intervalOverlapSeconds($from, $to, $nauticalDawnNext, $civilDawnNext);
|
||||
}
|
||||
|
||||
if ($visibleSeconds <= 0) {
|
||||
@@ -125,11 +130,24 @@ if (!function_exists('planetVisibilityClass')) {
|
||||
}
|
||||
|
||||
$nightRatio = $nightSeconds / $visibleSeconds;
|
||||
$darkRatio = ($nightSeconds + $nauticalSeconds) / $visibleSeconds;
|
||||
|
||||
if ($nightSeconds >= 3600 && $nightRatio >= 0.35) {
|
||||
return ['class' => 'planet-visibility-good', 'label' => 'nachts gut sichtbar'];
|
||||
}
|
||||
|
||||
if (($nightSeconds + $nauticalSeconds) >= 5400 && $darkRatio >= 0.35) {
|
||||
return ['class' => 'planet-visibility-good', 'label' => 'in dunkler Daemmerung gut sichtbar'];
|
||||
}
|
||||
|
||||
if ($nightSeconds > 0) {
|
||||
return ['class' => 'planet-visibility-warn', 'label' => 'nur teilweise in der astronomischen Nacht'];
|
||||
}
|
||||
|
||||
if ($nauticalSeconds > 0) {
|
||||
return ['class' => 'planet-visibility-warn', 'label' => 'nur in nautischer Daemmerung sichtbar'];
|
||||
}
|
||||
|
||||
if (($nightSeconds + $twilightSeconds) > 0) {
|
||||
return ['class' => 'planet-visibility-warn', 'label' => 'nur teilweise nachts / in der Dämmerung'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user