add parse_iso8691_date function #fix
This commit is contained in:
@@ -8,17 +8,17 @@ function parse_hex_color(text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function parse_iso8601_date(json_date)
|
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,
|
local year, month, day, hour, minute,
|
||||||
seconds, offsetsign, offsethour, offsetmin = json_date:match(pattern)
|
seconds, offsetsign, offsethour, offsetmin = json_date:match(pattern)
|
||||||
local timestamp = os.time{year = year, month = month,
|
local timestamp = os.time{year = year, month = month,
|
||||||
day = day, hour = hour, min = minute, sec = seconds}
|
day = day, hour = hour, min = minute, sec = seconds}
|
||||||
local offset = 0
|
local offset = 0
|
||||||
if offsetsign ~= 'Z' then
|
if offsetsign ~= '' and offsetsign ~= 'Z' then
|
||||||
offset = tonumber(offsethour) * 60 + tonumber(offsetmin)
|
offset = tonumber(offsethour) * 60 + tonumber(offsetmin)
|
||||||
if xoffset == "-" then offset = offset * -1 end
|
if xoffset == "-" then offset = offset * -1 end
|
||||||
end
|
end
|
||||||
|
|
||||||
return timestamp + offset
|
return timestamp + offset * 60
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user