aboutsummaryrefslogtreecommitdiffstats
path: root/lib/weather.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/weather.lua')
-rw-r--r--lib/weather.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/weather.lua b/lib/weather.lua
index f8c7517..84f355a 100644
--- a/lib/weather.lua
+++ b/lib/weather.lua
@@ -124,6 +124,11 @@ function M.sun_t(now, sunrise, sunset)
or type(sunset) ~= 'number' then return nil end
local span = sunset - sunrise
if span <= 0 then return 0 end -- polar day/night or bad data: no division
+ -- ponytail: a NaN timestamp slips through, since NaN is a number and every
+ -- comparison against it is false, so both clamps below fall through and this
+ -- returns NaN. Unreachable today: parse() matches %d+ for the sun times and
+ -- `now` is os.time(). Cairo ignores a NaN coordinate, so the cost would be a
+ -- missing dot, not a crash. Guard it here if a caller ever computes `now`.
local t = (now - sunrise) / span
if t < 0 then return 0 elseif t > 1 then return 1 end
return t