模块:CheckSignTime
require 'strict'
local p = {}
--提取签名中的时间,并转换为时间戳
local function sign2time(sign)
local timestamp = mw.ustring.match(sign, '%d%d%d%d年[1-9][0-2]?月[1-9]%d?日 %([一二三四五六日]*%) [0-2]%d:[0-5]%d %(UTC%)')
local year = tonumber(string.match(timestamp, '(%d%d%d%d)年'))
local month = tonumber(string.match(timestamp, '([1-9][0-2]?)月'))
local day = tonumber(string.match(timestamp, '([1-9]%d?)日'))
local hour = tonumber(string.match(timestamp, '([0-2]%d):'))
local min = tonumber(string.match(timestamp, ':([0-5]%d)'))
return os.time({year = year, month = month, day = day, hour = hour, min = min})
end
--返回签名中的时间戳
function p.sign(frame)
local args = require('Module:Arguments').getArgs(frame)
--local args = args.frame
return sign2time(args.sign)
end
--返回签名时间与当前时间的差值(秒)
function p.diff(frame)
local args = require('Module:Arguments').getArgs(frame)
return os.difftime(os.time(), sign2time(args.sign))
end
return p