This module intends to serve {{rft2}}
local export = {}
local m_para = require("Module:parameters")
-- for now, test with User:Pengo/tearoom2
function calc_dateinfo(year, month)
local output = {}
output = year
output = month
output = os.time{day=1, year=year, month=month}
output = os.date('%B', output) -- e.g. "October'
output = '/' .. year .. '/' .. output -- e.g. '/2015/October' (to form Wiktionary:Tea room/2015/October)
local expiryYear = year
local expiryMonth = month + 3
if (expiryMonth > 12) then
expiryYear = expiryYear + 1
expiryMonth = expiryMonth - 12
end
output = expiryYear
output = expiryMonth
output = os.time{day=1, year=expiryYear, month=expiryMonth}
local today = os.time()
if (today >= output) then
output = true
else
output = false
end
return output
end
function export.subst_rft(frame)
local wikitext = "{{tea room|y=" .. os.date('%Y') .. "|m=" .. os.date('%B');
iparams = {
= {}, -- reason entry was added to the Tea room for conversation
fragment = {}, -- title of Tea room discussion (for linking purposes)
}
local args = m_para.process(frame.args, iparams)
if args ~= nil then
wikitext = wikitext .. "|" .. args;
end
if args ~= nil then
wikitext = wikitext .. "|fragment=" .. args;
end
if args ~= nil then
wikitext = wikitext .. "|section=" .. args;
end
return wikitext .. "}}";
end
function export.rft(frame)
iparams = {
= {}, -- reason entry was added to the Tea room for conversation
fragment = {}, -- title of Tea room discussion (for linking purposes)
month = {required=true, type="number"}, -- month of discussion //TODO: allow month words
year = {required=true, type="number"} -- year of discussion
}
local iargs = m_para.process(frame.args, iparams)
local dateinfo = calc_dateinfo(iargs, iargs)
if (dateinfo) then
--print "expired"
else
--print "not expired"
return frame:expandTemplate{title = 'rft', args = iargs}
end
end
function export.rft_talk(frame)
iparams = {
= {}, -- reason entry was added to the Tea room for conversation
fragment = {}, -- title of Tea room discussion (for linking purposes)
month = {required=true, type="number"}, -- month of discussion. 1 = jan. 12 = dec. //TODO: allow month words, e.g. "OCT"
year = {required=true, type="number"} -- year of discussion
--nocat = {default=false, type="boolean"}
}
local iargs = m_para.process(frame.args, iparams)
local dateinfo = calc_dateinfo(iargs, iargs)
local frag = ''
if iargs ~= nil then
frag = '#' .. iargs
end
if (dateinfo) then
return "expired: .. frag .. ']]';
else
return "not yet expired. archival url: .. frag .. "]]. "
.. "current url: ]";
end
end
return export