aboutsummaryrefslogtreecommitdiffstats
path: root/lib/weather.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/weather.lua')
-rw-r--r--lib/weather.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/weather.lua b/lib/weather.lua
index a66d79a..d36bcf5 100644
--- a/lib/weather.lua
+++ b/lib/weather.lua
@@ -165,10 +165,13 @@ function M.parse(src)
local w = {
id = tonumber(cond:match('"id"%s*:%s*(%-?%d+)')),
description = cond:match('"description"%s*:%s*"([^"]*)"'),
- temp = tonumber(main:match('"temp"%s*:%s*(%-?[%d%.]+)')),
- feels_like = tonumber(main:match('"feels_like"%s*:%s*(%-?[%d%.]+)')),
+ -- The exponent is accepted although OWM has never been seen to emit one:
+ -- a pattern stopping at the 'e' would read 1.8e1 as 1.8 and draw 2 degrees
+ -- instead of 18, silently and plausibly. Cheaper to accept than to detect.
+ temp = tonumber(main:match('"temp"%s*:%s*(%-?[%d%.eE%+%-]+)')),
+ feels_like = tonumber(main:match('"feels_like"%s*:%s*(%-?[%d%.eE%+%-]+)')),
humidity = tonumber(main:match('"humidity"%s*:%s*(%d+)')),
- wind_speed = tonumber(wind:match('"speed"%s*:%s*([%d%.]+)')),
+ wind_speed = tonumber(wind:match('"speed"%s*:%s*([%d%.eE%+%-]+)')),
wind_deg = tonumber(wind:match('"deg"%s*:%s*(%d+)')),
sunrise = tonumber(sys:match('"sunrise"%s*:%s*(%d+)')),
sunset = tonumber(sys:match('"sunset"%s*:%s*(%d+)')),