From 296ed2a05af2e047eb9480c2046d18413ef781a5 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Tue, 20 Apr 2021 16:38:04 +0200 Subject: [PATCH] Improve list-hourly-weather.ps1 --- Scripts/list-hourly-weather.ps1 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Scripts/list-hourly-weather.ps1 b/Scripts/list-hourly-weather.ps1 index 4fa398ee..b126dda0 100755 --- a/Scripts/list-hourly-weather.ps1 +++ b/Scripts/list-hourly-weather.ps1 @@ -13,11 +13,11 @@ try { $Area = $Weather.nearest_area.areaName.value $Region = $Weather.nearest_area.region.value - $Country = $Weather.nearest_area.country.value - "🕗 Hourly weather today at $Area ($Region, $Country)" + $Country = $Weather.nearest_area.country.value - [int]$Hour = 0 + [int]$Day = 0 foreach ($Hourly in $Weather.weather.hourly) { + $Hour = $Hourly.time / 100 $Temp = $Hourly.tempC $Precip = $Hourly.precipMM $Humidity = $Hourly.humidity @@ -28,6 +28,16 @@ try { $Visib = $Hourly.visibility $Clouds = $Hourly.cloudcover $Desc = $Hourly.weatherDesc.value + if ($Hour -eq 0) { + if ($Day -eq 0) { + "🕗 Today at $Area ($Region, $Country)" + } elseif ($Day -eq 1) { + "🕗 Tomorrow" + } else { + "🕗 Day After Tomorrow" + } + $Day++ + } "$($Hour)°°`t$($Temp)°C`t$($Precip)mm $($Humidity)%`t$($WindSpeed)km/h from $WindDir`t$($Pressure)hPa UV$($UV) $($Visib)km $($Clouds)% $Desc" $Hour++ }