# HG changeset patch # User Kim Alvefur # Date 1689528438 -7200 # Node ID 278920294dfefd805b24a1309d3c6d90a0a426ef # Parent 313c49c7566aeadd49f8a52c9e79cf0c1f80310e 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. diff -r 313c49c7566a -r 278920294dfe util/human/io.lua --- a/util/human/io.lua Sun Jul 16 19:26:05 2023 +0200 +++ b/util/human/io.lua Sun Jul 16 19:27:18 2023 +0200 @@ -197,10 +197,10 @@ 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