1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 22:57:46 +00:00

updates get-weather to remove the for loop (#313)

This commit is contained in:
Darren Schroeder 2022-11-12 17:22:10 -06:00 committed by GitHub
parent c3abd6439c
commit 73e67b8054
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -70,10 +70,10 @@ def get_weather_by_ip [locIdx: int, units: string, token: string] {
let url_forecast = $"($URL_FORECAST)?lat=($coords.lat.0)&lon=($coords.lon.0)&units=($units)&appid=($token)"
let weather = (fetch $url)
let forecast_data = (fetch $url_forecast)
let forecast = (for day in $forecast_data.list {
let forecast = ($forecast_data.list | each {|day|
{
id: ($day.weather.0.id)
dt: ($day.dt | into string | into datetime -z local | date format '%Y-%m-%d')
dt: ($day.dt | into string | into datetime -z local | date format '%a, %b %e') #'%Y-%m-%d')
high: ($day.temp.max)
low: ($day.temp.min)
}
@ -111,7 +111,7 @@ def get_weather_by_ip [locIdx: int, units: string, token: string] {
let forecast = (for day in $forecast_data.list {
{
id: ($day.weather.0.id)
dt: ($day.dt | into string | into datetime -z local | date format '%Y-%m-%d')
dt: ($day.dt | into string | into datetime -z local | date format '%a, %b %e') #'%Y-%m-%d')
high: ($day.temp.max)
low: ($day.temp.min)
}