Improve list-hourly-weather.ps1

This commit is contained in:
Markus Fleschutz 2021-04-20 16:38:04 +02:00
parent 63d5f5c796
commit 296ed2a05a

View File

@ -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++
}