diff --git a/app/Http/Controllers/WeatherController.php b/app/Http/Controllers/WeatherController.php
index 92035c4..44407cc 100644
--- a/app/Http/Controllers/WeatherController.php
+++ b/app/Http/Controllers/WeatherController.php
@@ -53,10 +53,7 @@ class WeatherController extends Controller
'detailedForecast' => $period->detailed_forecast,
]);
- $background = $this->getBackgroundForForecast(
- $currentPeriod?->short_forecast,
- $currentPeriod?->is_daytime ?? true
- );
+ $background = $this->getBackgroundForForecast($currentPeriod?->short_forecast);
return Inertia::render('Weather', [
'current' => $currentPeriod ? [
@@ -87,10 +84,10 @@ class WeatherController extends Controller
/**
* @return array{imageUrl: string|null, licenseHtml: string|null}
*/
- private function getBackgroundForForecast(?string $forecast, bool $isDaytime): array
+ private function getBackgroundForForecast(?string $forecast): array
{
$folder = $this->mapForecastToFolder($forecast);
- $timeOfDay = $isDaytime ? 'day' : 'night';
+ $timeOfDay = $this->isCurrentlyDaytime() ? 'day' : 'night';
$basePath = storage_path('app/public/backgrounds/'.$folder);
if (! File::isDirectory($basePath)) {
@@ -153,6 +150,16 @@ class WeatherController extends Controller
};
}
+ private function isCurrentlyDaytime(): bool
+ {
+ $sunriseHour = 6.75; // 6:45 AM
+ $sunsetHour = 17.5; // 5:30 PM
+
+ $currentHour = now()->hour + (now()->minute / 60);
+
+ return $currentHour >= $sunriseHour && $currentHour < $sunsetHour;
+ }
+
private function mapIconToEmoji(?string $forecast): string
{
if (! $forecast) {
diff --git a/resources/js/pages/Weather.vue b/resources/js/pages/Weather.vue
index 8dafdfc..c0754de 100644
--- a/resources/js/pages/Weather.vue
+++ b/resources/js/pages/Weather.vue
@@ -104,14 +104,8 @@ const sunPosition = computed(() => {
const isDaytime = t >= 0 && t <= 1;
if (!isDaytime) {
- // Nighttime: position sun below horizon
- // Before sunrise: position on left side below horizon
- // After sunset: position on right side below horizon
- if (currentHour < sunriseHour) {
- return { cx: 20, cy: 85 };
- } else {
- return { cx: 180, cy: 85 };
- }
+ // Nighttime: show moon at top of arc
+ return { cx: 100, cy: 10, isNight: true };
}
// Quadratic bezier curve: M 10 70 Q 100 -10 190 70
@@ -127,7 +121,7 @@ const sunPosition = computed(() => {
const cx = oneMinusT * oneMinusT * p0.x + 2 * oneMinusT * t * p1.x + t * t * p2.x;
const cy = oneMinusT * oneMinusT * p0.y + 2 * oneMinusT * t * p1.y + t * t * p2.y;
- return { cx: Math.round(cx), cy: Math.round(cy) };
+ return { cx: Math.round(cx), cy: Math.round(cy), isNight: false };
});
const formattedSunrise = computed(() => {
@@ -269,14 +263,23 @@ const formattedSunset = computed(() => {
stroke-width="2"
stroke-dasharray="4 4"
/>
-
+