aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2013-12-15 02:48:00 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2013-12-15 17:47:49 +0100
commit7961ca145479e364fe64ec082e24545bd0f3c4bb (patch)
tree2bdd1c50b361e866fb74775d1a792e9093d0e481
parentdc556e5415ee1d1b3b74508e016fb1693d55a311 (diff)
downloadvicious-legacy-7961ca145479e364fe64ec082e24545bd0f3c4bb.tar.xz
weather: add support for dew point
Signed-off-by: Jonathan McCrohan <jmccrohan@gmail.com> Signed-off-by: Adrian C. (anrxc) <anrxc@sysphere.org>
-rw-r--r--README3
-rw-r--r--widgets/weather.lua8
2 files changed, 10 insertions, 1 deletions
diff --git a/README b/README
index f86e6bf..09b7abd 100644
--- a/README
+++ b/README
@@ -282,7 +282,8 @@ vicious.widgets.weather
- provides weather information for a requested station
- takes the ICAO station code as an argument, i.e. "LDRI"
- returns a table with string keys: {city}, {wind}, {windmph},
- {windkmh}, {sky}, {weather}, {tempf}, {tempc}, {humid}, {press}
+ {windkmh}, {sky}, {weather}, {tempf}, {tempc}, {humid}, {dewf},
+ {dewc}, {press}
vicious.widgets.date
- provides access to os.date, with optional time formatting provided
diff --git a/widgets/weather.lua b/widgets/weather.lua
index 356f32f..029df7e 100644
--- a/widgets/weather.lua
+++ b/widgets/weather.lua
@@ -28,6 +28,8 @@ local _weather = {
["{weather}"] = "N/A",
["{tempf}"] = "N/A",
["{tempc}"] = "N/A",
+ ["{dewf}"] = "N/A",
+ ["{dewc}"] = "N/A",
["{humid}"] = "N/A",
["{press}"] = "N/A"
}
@@ -58,6 +60,8 @@ local function worker(format, warg)
string.match(ws, "Weather:[%s](.-)[%c]") or _weather["{weather}"]
_weather["{tempf}"] = -- Temperature in fahrenheit
string.match(ws, "Temperature:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{tempf}"]
+ _weather["{dewf}"] = -- Dew Point in fahrenheit
+ string.match(ws, "Dew[%s]Point:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{dewf}"]
_weather["{humid}"] = -- Relative humidity in percent
string.match(ws, "Relative[%s]Humidity:[%s]([%d]+)%%") or _weather["{humid}"]
_weather["{press}"] = -- Pressure in hPa
@@ -71,6 +75,10 @@ local function worker(format, warg)
if _weather["{tempf}"] ~= "N/A" then
_weather["{tempf}"] = tonumber(_weather["{tempf}"])
_weather["{tempc}"] = math.ceil((_weather["{tempf}"] - 32) * 5/9)
+ end -- Dew Point in °C if °F was available
+ if _weather["{dewf}"] ~= "N/A" then
+ _weather["{dewf}"] = tonumber(_weather["{dewf}"])
+ _weather["{dewc}"] = math.ceil((_weather["{dewf}"] - 32) * 5/9)
end -- Capitalize some stats so they don't look so out of place
if _weather["{sky}"] ~= "N/A" then
_weather["{sky}"] = helpers.capitalize(_weather["{sky}"])