From 82a4075f41e22e445a9c8f2d2d71573780627fcd Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 3 Jun 2022 20:18:17 +0300 Subject: [PATCH] add parse_iso8691_date function #fix --- lib/misc.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/misc.lua b/lib/misc.lua index cd07596..bf11647 100644 --- a/lib/misc.lua +++ b/lib/misc.lua @@ -8,17 +8,17 @@ function parse_hex_color(text) end function parse_iso8601_date(json_date) - local pattern = "(%d+)%-(%d+)%-(%d+)%a(%d+)%:(%d+)%:([%d%.]+)([Z%+%-])(%d?%d?)%:?(%d?%d?)" + local pattern = "(%d+)%-(%d+)%-(%d+)%a(%d+)%:(%d+)%:([%d%.]+)([Z%+%-]?)(%d?%d?)%:?(%d?%d?)" local year, month, day, hour, minute, seconds, offsetsign, offsethour, offsetmin = json_date:match(pattern) local timestamp = os.time{year = year, month = month, day = day, hour = hour, min = minute, sec = seconds} local offset = 0 - if offsetsign ~= 'Z' then + if offsetsign ~= '' and offsetsign ~= 'Z' then offset = tonumber(offsethour) * 60 + tonumber(offsetmin) if xoffset == "-" then offset = offset * -1 end end - return timestamp + offset + return timestamp + offset * 60 end