【发布时间】:2013-12-23 12:26:01
【问题描述】:
假设我有以下提醒时间戳
local reminder_timestamp = "2013-12-13T00:00:00+01:00"
我正在使用以下函数以 UTC 格式返回时间
local function makeTimeStamp(dateString)
local pattern = "(%d+)%-(%d+)%-(%d+)%a(%d+)%:(%d+)%:([%d%.]+)([Z%p])(%d%d)%:?(%d%d)"
local year, month, day, hour, minute, seconds, tzoffset, offsethour, offsetmin = dateString:match(pattern)
local timestamp = os.time( {year=year, month=month, day=day, hour=hour, min=minute, sec=seconds} )
local offset = 0
if ( tzoffset ) then
if ( tzoffset == "+" or tzoffset == "-" ) then -- we have a timezone!
offset = offsethour * 60 + offsetmin
if ( tzoffset == "-" ) then
offset = offset * -1
end
timestamp = timestamp + offset
end
end
return timestamp
end
上面的模式应该是什么来匹配我之前提到的提醒时间戳?
【问题讨论】: