From afd51e20bb19881c149cced856f7573fc64ec50d Mon Sep 17 00:00:00 2001 From: Aleksandr Beliaev Date: Fri, 27 May 2016 13:01:58 +1200 Subject: [PATCH] modified: widgets/weather.lua - fixed the OWM "feature" for icon day/night state calculated in accordance with current GMT time (it seems OWM knows nothing of local time and time zones) --- widgets/weather.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/widgets/weather.lua b/widgets/weather.lua index ca0ceed..f60a8fc 100644 --- a/widgets/weather.lua +++ b/widgets/weather.lua @@ -117,11 +117,20 @@ local function worker(args) function weather.update() local cmd = string.format(current_call, city_id, units, lang, APPID) async.request(cmd, function(f) - local pos, err + local pos, err, sunrise, sunset, current_dt, datetime, icon weather_now, pos, err = json.decode(f, 1, nil) if not err and weather_now and tonumber(weather_now["cod"]) == 200 then - weather.icon_path = icons_path .. weather_now["weather"][1]["icon"] .. ".png" + current_dt = os.time() + sunrise = weather_now["sys"]["sunrise"] + sunset = weather_now["sys"]["sunset"] + if current_dt > sunrise and current_dt < sunset then + datetime="d" + else + datetime="n" + end + icon = weather_now["weather"][1]["icon"] + weather.icon_path = icons_path .. icon:sub(1,2) .. datetime .. ".png" widget = weather.widget settings() else -- 2.39.5