Jump to content

Module:Sandbox/CanonNi

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by CanonNi (talk | contribs) at 07:53, 2 November 2024 (error handling). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local Date = require('Module:Date')._Date
local current = require('Module:Date')._current
local Error

local p = {}

function p.main(frame)
	local day
	
	if frame.args[1] ~= nil then
		if pcall(function() return Date(frame.args[1]):text('dmy') end) then
			day = Date(frame.args[1]):text('dmy')
		else
			Error = require('Module:Error')
			Error.error('Invalid date format in Template:Update')
		end
	else
		day = Date(current.year, current.month, current.day):text('dmy')
	end
	
	return ": ''As of " .. day .. (frame.args[2] or '')
end

return p