我有一个文件(termino.txt),全部用以下格式填充:
- 付款
- 2015 - 08 - 30 t13:22:53.108z
- 去看医生
- 2015 - 09 - 30 t13:22:53.108z
- …
所有的偶数行都是RFC 3339形式的时间戳。我需要的是对比一下今天的日期和文件中的这些日期是否相同。我正在尝试这个:
local function verifica(evt)
local nome= ''
local dia = ''
local turn = 1
local data = os.date("%x")
local file = io.open("termino.txt", "r")
while true do
nome = dia
line = file:read()
dia = line
if (turn %2 == 0) then
> Here I need to compare "data" with "dia" that will receive string with RFC 3339 timestamp format.
end
turn ++
end
end
我需要帮助来做这个比较!由于
local dia = '2015-10-6T13:22:53.108Z'
-- parse date info from the RFC 3339 timestamp
local year, month, day = dia:match('(%d+)-(%d+)-(%d+)')
-- get today's date from Lua, in table format
local today = os.date('*t')
-- compare
if tonumber(year) == today.year
and tonumber(month) == today.month
and tonumber(day) == today.day then
-- the dates match
end