aboutsummaryrefslogtreecommitdiffstats
path: root/lib/weather.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/weather.lua')
-rw-r--r--lib/weather.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/weather.lua b/lib/weather.lua
index 4eab3ac..0b4b1b7 100644
--- a/lib/weather.lua
+++ b/lib/weather.lua
@@ -41,8 +41,12 @@ M.ICON = {
-- face for the conditions that have both.
function M.icon(id, now, sunrise, sunset)
if type(id) ~= 'number' then return M.ICON.unknown end
+ -- `now` is guarded alongside sunrise and sunset, not just them: comparing a
+ -- nil now against a number raises, and a raise here is a blank dashboard.
+ -- Missing any of the three means the sun is unknown, so the day face is
+ -- drawn, which is what is_day() falls back to as well.
local day = true
- if sunrise and sunset then day = (now >= sunrise and now <= sunset) end
+ if now and sunrise and sunset then day = (now >= sunrise and now <= sunset) end
local function pick(d, n) return day and d or n end
if id <= 232 then return pick(M.ICON.thunder_day, M.ICON.thunder_night)