aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-07-16 19:27:18 +0200
committerKim Alvefur <zash@zash.se>2023-07-16 19:27:18 +0200
commitbb760b136300b4fa5a2829a42f7c0d869e36ec2f (patch)
tree0892385fd29fbe3de52fddcc96b8776688c14173 /util
parent3ab3f3e1e7a70c9e466e1715a33d2c7a0ed08b1a (diff)
downloadprosody-bb760b136300b4fa5a2829a42f7c0d869e36ec2f.tar.gz
prosody-bb760b136300b4fa5a2829a42f7c0d869e36ec2f.zip
util.human.io: Fix pattern in parse_duration() to cover all used letters
Notably 'h' was missing. Awkwardly, 'hour' would result in 'ho' which was missing from table.
Diffstat (limited to 'util')
-rw-r--r--util/human/io.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/util/human/io.lua b/util/human/io.lua
index 5049f244..542e4ceb 100644
--- a/util/human/io.lua
+++ b/util/human/io.lua
@@ -197,10 +197,10 @@ end
local day = 86400;
local multipliers = {
d = day, w = day * 7, m = 31 * day, mo = 31 * day, y = 365.2425 * day;
- s = 1, mi = 60, h = 3600
+ s = 1, mi = 60, h = 3600, ho = 3600
};
local function parse_duration(duration_string)
- local n, m = duration_string:lower():match("(%d+)%s*([dwmy]?.?)");
+ local n, m = duration_string:lower():match("(%d+)%s*([smhdwy]?[io]?)");
if not n then return nil; end
return tonumber(n) * ( multipliers[m] or 1 );
end