Module:Timebomb

require('Module:No globals') local getArgs = require('Module:Arguments').getArgs local lang = mw.language.new('en')

local p = { }

local function length(timebomb, compiled) local ts1 = lang:formatDate('U', timebomb) local ts2 = lang:formatDate('U', compiled) return lang:formatDuration(ts1 - ts2, {"days"}) end

function classic(timebomb, compiled) local length = length(timebomb, compiled) local clean = lang:formatDate('Y-m-d', timebomb)

return clean .. ' ' .. length .. '' end

function dynamic(timebomb) return length(timebomb, 'now') end

function p.main(frame) local args = getArgs(frame) if not args.timebomb then return "" end if args.timebomb:byte == '+' then return dynamic(args.timebomb) else return classic(args.timebomb, args.compiled) end end

return p