From: Aleksandr Beliaev Date: Mon, 11 Sep 2017 04:51:52 +0000 (+1200) Subject: Weather widget rewritten; first authorship updated X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/31d64906a0ebfbccb2ac76f50be7be6ed73c3a24?ds=inline;hp=-c Weather widget rewritten; first authorship updated --- 31d64906a0ebfbccb2ac76f50be7be6ed73c3a24 diff --git a/helpers.lua b/helpers.lua index b5b663d..6073ddd 100644 --- a/helpers.lua +++ b/helpers.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ --]] diff --git a/init.lua b/init.lua index 46c7659..b59d5dd 100644 --- a/init.lua +++ b/init.lua @@ -4,7 +4,7 @@ Layouts, widgets and utilities for Awesome WM Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ --]] diff --git a/layout/cascade.lua b/layout/cascade.lua index f7dffb9..cbc3877 100644 --- a/layout/cascade.lua +++ b/layout/cascade.lua @@ -2,7 +2,7 @@ Licensed under GNU General Public License v2 * (c) 2014, projektile - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/layout/centerwork.lua b/layout/centerwork.lua index aff2771..d1394a1 100644 --- a/layout/centerwork.lua +++ b/layout/centerwork.lua @@ -4,7 +4,7 @@ * (c) 2016, Henrik Antonsson * (c) 2015, Joerg Jaspert * (c) 2014, projektile - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/layout/init.lua b/layout/init.lua index b311f45..6478b06 100644 --- a/layout/init.lua +++ b/layout/init.lua @@ -6,7 +6,7 @@ Layouts section Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/layout/termfair.lua b/layout/termfair.lua index 60b3c7d..f57f715 100644 --- a/layout/termfair.lua +++ b/layout/termfair.lua @@ -2,7 +2,7 @@ Licensed under GNU General Public License v2 * (c) 2014, projektile - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010, Nicolas Estibals * (c) 2010-2012, Peter Hofmann diff --git a/util/init.lua b/util/init.lua index 8e7b8ef..8b8e719 100644 --- a/util/init.lua +++ b/util/init.lua @@ -6,7 +6,7 @@ Utilities section Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/util/markup.lua b/util/markup.lua index 0eb9bfa..9801331 100644 --- a/util/markup.lua +++ b/util/markup.lua @@ -1,7 +1,7 @@ --[[ Licensed under MIT License - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2009, Uli Schlachter * (c) 2009, Majic diff --git a/util/quake.lua b/util/quake.lua index 38b9917..6271fcd 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2016, Luke Bonham + * (c) 2016, Luca CPZ * (c) 2015, unknown --]] diff --git a/util/separators.lua b/util/separators.lua index c86af92..29d3005 100644 --- a/util/separators.lua +++ b/util/separators.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2015, Luke Bonham + * (c) 2015, Luca CPZ * (c) 2015, plotnikovanton --]] diff --git a/widget/alsa.lua b/widget/alsa.lua index 29e3a05..2d4891d 100644 --- a/widget/alsa.lua +++ b/widget/alsa.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010, Adrian C. --]] diff --git a/widget/alsabar.lua b/widget/alsabar.lua index 750933a..125b992 100644 --- a/widget/alsabar.lua +++ b/widget/alsabar.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2013, Rman --]] diff --git a/widget/bat.lua b/widget/bat.lua index d48b12a..34d63e5 100644 --- a/widget/bat.lua +++ b/widget/bat.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/widget/calendar.lua b/widget/calendar.lua index 4f927b3..84b025d 100644 --- a/widget/calendar.lua +++ b/widget/calendar.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ --]] diff --git a/widget/contrib/init.lua b/widget/contrib/init.lua index ccc1046..9e863a5 100644 --- a/widget/contrib/init.lua +++ b/widget/contrib/init.lua @@ -6,7 +6,7 @@ Users contributed widgets section Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ --]] diff --git a/widget/contrib/tpbat/init.lua b/widget/contrib/tpbat/init.lua index d926e8e..e9675ef 100644 --- a/widget/contrib/tpbat/init.lua +++ b/widget/contrib/tpbat/init.lua @@ -8,7 +8,7 @@ Licensed under GNU General Public License v2 * (c) 2013, Conor Heine - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/widget/cpu.lua b/widget/cpu.lua index b6ecb9c..6c6e77a 100644 --- a/widget/cpu.lua +++ b/widget/cpu.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/widget/fs.lua b/widget/fs.lua index 09e2ef5..ca6fb4d 100644 --- a/widget/fs.lua +++ b/widget/fs.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ --]] diff --git a/widget/imap.lua b/widget/imap.lua index 17f37cf..7c13223 100644 --- a/widget/imap.lua +++ b/widget/imap.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ --]] diff --git a/widget/init.lua b/widget/init.lua index e3315d4..57b86bb 100644 --- a/widget/init.lua +++ b/widget/init.lua @@ -6,7 +6,7 @@ Widgets section Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/widget/mem.lua b/widget/mem.lua index fa2c364..3dcae2b 100644 --- a/widget/mem.lua +++ b/widget/mem.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/widget/mpd.lua b/widget/mpd.lua index 38c49dd..ff45179 100644 --- a/widget/mpd.lua +++ b/widget/mpd.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010, Adrian C. --]] diff --git a/widget/net.lua b/widget/net.lua index 1780d78..987f047 100644 --- a/widget/net.lua +++ b/widget/net.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/widget/pulse.lua b/widget/pulse.lua index aa9d58e..d37e83a 100644 --- a/widget/pulse.lua +++ b/widget/pulse.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2016, Luke Bonham + * (c) 2016, Luca CPZ --]] diff --git a/widget/pulsebar.lua b/widget/pulsebar.lua index 7a0a3d4..78b7d49 100644 --- a/widget/pulsebar.lua +++ b/widget/pulsebar.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2013, Rman --]] diff --git a/widget/sysload.lua b/widget/sysload.lua index 98c0ff7..adf3e03 100644 --- a/widget/sysload.lua +++ b/widget/sysload.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ * (c) 2010-2012, Peter Hofmann --]] diff --git a/widget/temp.lua b/widget/temp.lua index cc9f056..3c93252 100644 --- a/widget/temp.lua +++ b/widget/temp.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham + * (c) 2013, Luca CPZ --]] diff --git a/widget/weather.lua b/widget/weather.lua index b75afc8..a9b886a 100644 --- a/widget/weather.lua +++ b/widget/weather.lua @@ -1,7 +1,7 @@ --[[ Licensed under GNU General Public License v2 - * (c) 2015, Luke Bonham + * (c) 2015, Luca CPZ --]] @@ -20,7 +20,7 @@ local math, os, string, tonumber = math, os, string, tonumber local function factory(args) local weather = { widget = wibox.widget.textbox() } local args = args or {} - local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default + local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain's default local timeout = args.timeout or 60 * 15 -- 15 min local timeout_forecast = args.timeout or 60 * 60 * 24 -- 24 hrs local current_call = args.current_call or "curl -s 'http://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s&APPID=%s'" @@ -114,22 +114,18 @@ local function factory(args) local sunrise = tonumber(weather_now["sys"]["sunrise"]) local sunset = tonumber(weather_now["sys"]["sunset"]) local icon = weather_now["weather"][1]["icon"] - local loc_now = os.time() - local loc_m = os.time { year = os.date("%Y"), month = os.date("%m"), day = os.date("%d"), hour = 0 } - local loc_t = os.difftime(loc_now, loc_m) - local loc_d = os.date("*t", loc_now) - local utc_d = os.date("!*t", loc_now) - local utc_now = os.time(utc_d) - local offdt = (loc_d.isdst and 1 or 0) * 3600 + 100 * (loc_d.min - utc_d.min) / 60 - local offset = os.difftime(loc_now, utc_now) + offdt - local offday = (offset < 0 and -86400) or 86400 - - if math.abs(loc_now - utc_now - offdt + loc_t) >= 86400 then - utc_now = utc_now + offday - end - - if offday * (loc_now - utc_now - offdt) > 0 then - sunrise = sunrise + offday + local loc_now = os.time() -- local time + local loc_m = os.time { year = os.date("%Y"), month = os.date("%m"), day = os.date("%d"), hour = 0 } -- local time from midnight + local loc_d = os.date("*t", loc_now) -- table YMDHMS for current local time (for TZ calculation) + local utc_d = os.date("!*t", loc_now) -- table YMDHMS for current UTC time + local utc_now = os.time(utc_d) -- UTC time now + local offdt = (loc_d.isdst and 1 or 0) * 3600 + 100 * (loc_d.min - utc_d.min) / 60 -- DST offset + local offset = os.difftime(loc_now, utc_now) + (loc_d.isdst and 1 or 0) * 3600 + 100 * (loc_d.min - utc_d.min) / 60 -- TZ offset (including DST) + local offday = (offset < 0 and -86400) or 86400 -- 24 hour correction value (+86400 or -86400) + + -- if current UTC time is earlier then local midnight -> positive offset (negative otherwise) + if offset * (loc_m - utc_now + offdt) > 0 then + sunrise = sunrise + offday -- Shift sunset and sunrise times by 24 hours sunset = sunset + offday end diff --git a/wiki b/wiki index b0eb668..2859d40 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit b0eb6680557d182bc0c9379d0294913f93e33a27 +Subproject commit 2859d4049cf9b96ffa8ac2c872428d730b6477c9