mirror of https://github.com/lcpz/lain.git
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)
This commit is contained in:
parent
6fd1eecd43
commit
afd51e20bb
|
@ -117,11 +117,20 @@ local function worker(args)
|
||||||
function weather.update()
|
function weather.update()
|
||||||
local cmd = string.format(current_call, city_id, units, lang, APPID)
|
local cmd = string.format(current_call, city_id, units, lang, APPID)
|
||||||
async.request(cmd, function(f)
|
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)
|
weather_now, pos, err = json.decode(f, 1, nil)
|
||||||
|
|
||||||
if not err and weather_now and tonumber(weather_now["cod"]) == 200 then
|
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
|
widget = weather.widget
|
||||||
settings()
|
settings()
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue