<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.roatpkz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ACountdown</id>
	<title>Module:Countdown - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.roatpkz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ACountdown"/>
	<link rel="alternate" type="text/html" href="https://wiki.roatpkz.com/index.php?title=Module:Countdown&amp;action=history"/>
	<updated>2026-04-05T00:08:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.roatpkz.com/index.php?title=Module:Countdown&amp;diff=21601&amp;oldid=prev</id>
		<title>Hefner: Created page with &quot;-- This module powers {{countdown}}.  local p = {}  -- Constants local lang = mw.language.getContentLanguage() local getArgs = require(&#039;Module:Arguments&#039;).getArgs  local function formatMessage(secondsLeft, event, color) 	local timeLeft = lang:formatDuration(secondsLeft, {&#039;years&#039;, &#039;weeks&#039;, &#039;days&#039;, &#039;hours&#039;, &#039;minutes&#039;, &#039;seconds&#039;}) 	-- Find whether we are plural or not. 	local isOrAre 	if string.match(timeLeft, &#039;^%d+&#039;) == &#039;1&#039; then 		isOrAre = &#039;is&#039; 	else 		isOrAre = &#039;are&#039; 	en...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.roatpkz.com/index.php?title=Module:Countdown&amp;diff=21601&amp;oldid=prev"/>
		<updated>2024-05-07T19:15:12Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;-- This module powers {{countdown}}.  local p = {}  -- Constants local lang = mw.language.getContentLanguage() local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs  local function formatMessage(secondsLeft, event, color) 	local timeLeft = lang:formatDuration(secondsLeft, {&amp;#039;years&amp;#039;, &amp;#039;weeks&amp;#039;, &amp;#039;days&amp;#039;, &amp;#039;hours&amp;#039;, &amp;#039;minutes&amp;#039;, &amp;#039;seconds&amp;#039;}) 	-- Find whether we are plural or not. 	local isOrAre 	if string.match(timeLeft, &amp;#039;^%d+&amp;#039;) == &amp;#039;1&amp;#039; then 		isOrAre = &amp;#039;is&amp;#039; 	else 		isOrAre = &amp;#039;are&amp;#039; 	en...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module powers {{countdown}}.&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Constants&lt;br /&gt;
local lang = mw.language.getContentLanguage()&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
&lt;br /&gt;
local function formatMessage(secondsLeft, event, color)&lt;br /&gt;
	local timeLeft = lang:formatDuration(secondsLeft, {&amp;#039;years&amp;#039;, &amp;#039;weeks&amp;#039;, &amp;#039;days&amp;#039;, &amp;#039;hours&amp;#039;, &amp;#039;minutes&amp;#039;, &amp;#039;seconds&amp;#039;})&lt;br /&gt;
	-- Find whether we are plural or not.&lt;br /&gt;
	local isOrAre&lt;br /&gt;
	if string.match(timeLeft, &amp;#039;^%d+&amp;#039;) == &amp;#039;1&amp;#039; then&lt;br /&gt;
		isOrAre = &amp;#039;is&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		isOrAre = &amp;#039;are&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	-- Color and bold the numbers, because it makes them look important.&lt;br /&gt;
	timeLeft = string.gsub(timeLeft, &amp;#039;(%d+)&amp;#039;, &amp;#039;&amp;lt;span style=&amp;quot;color: &amp;#039; .. (color or &amp;#039;#F00&amp;#039;) .. &amp;#039;; font-weight: bold;&amp;quot;&amp;gt;%1&amp;lt;/span&amp;gt;&amp;#039;)&lt;br /&gt;
	return string.format(&amp;#039;There %s %s until %s.&amp;#039;, isOrAre, timeLeft, event)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
&lt;br /&gt;
	if not (args.year and args.month and args.day) then&lt;br /&gt;
		return &amp;#039;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;Error: year, month, and day must be specified&amp;lt;/strong&amp;gt;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local timeArgs = {year=args.year, month=args.month, day=args.day, hour=args.hour, min=args.minute, sec=args.second}&lt;br /&gt;
	for k,v in pairs(timeArgs) do&lt;br /&gt;
		if not tonumber(v) then&lt;br /&gt;
			error(&amp;#039;Argument &amp;#039; .. k .. &amp;#039; could not be parsed as a number: &amp;#039; .. v)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local eventTime = os.time(timeArgs)&lt;br /&gt;
	local timeToStart = os.difftime(eventTime, os.time()) -- (future time - current time)&lt;br /&gt;
	local text&lt;br /&gt;
	if timeToStart &amp;gt; 0 then&lt;br /&gt;
		-- Event has not begun yet&lt;br /&gt;
		text = formatMessage(timeToStart, args.event or &amp;#039;the event begins&amp;#039;, args.color)&lt;br /&gt;
	elseif args.duration then&lt;br /&gt;
		local timeToEnd&lt;br /&gt;
		if args[&amp;#039;duration unit&amp;#039;] then&lt;br /&gt;
			-- Duration is in unit other than seconds, use formatDate to add&lt;br /&gt;
			timeToEnd = tonumber(lang:formatDate(&amp;#039;U&amp;#039;, &amp;#039;@&amp;#039; .. tostring(timeToStart) .. &amp;#039; +&amp;#039; .. tostring(args.duration) .. &amp;#039; &amp;#039; .. args[&amp;#039;duration unit&amp;#039;]))&lt;br /&gt;
		else&lt;br /&gt;
			timeToEnd = timeToStart + (tonumber(args.duration) or error(&amp;#039;args.duration should be a number of seconds&amp;#039;, 0))&lt;br /&gt;
		end&lt;br /&gt;
		if timeToEnd &amp;gt; 0 then&lt;br /&gt;
			-- Event is in progress&lt;br /&gt;
			text = args.eventstart or formatMessage(timeToEnd, (args.event or &amp;#039;the event&amp;#039;) .. &amp;#039; ends&amp;#039;, args.color)&lt;br /&gt;
		else&lt;br /&gt;
			-- Event had a duration and has now ended&lt;br /&gt;
			text = args.eventend or ((lang:ucfirst(args.event or &amp;#039;The event&amp;#039;)) .. &amp;#039; has ended.&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		-- Event had no duration and has begun&lt;br /&gt;
		text = args.eventstart or ((lang:ucfirst(args.event or &amp;#039;The event&amp;#039;)) .. &amp;#039; has started.&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	local refreshLink&lt;br /&gt;
	if args.refresh == &amp;#039;no&amp;#039; then&lt;br /&gt;
		refreshLink = &amp;#039;&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		refreshLink = mw.title.getCurrentTitle():fullUrl({action = &amp;#039;purge&amp;#039;})&lt;br /&gt;
		refreshLink = string.format(&amp;#039; &amp;lt;small&amp;gt;&amp;lt;span class=&amp;quot;plainlinks&amp;quot;&amp;gt;([%s refresh])&amp;lt;/span&amp;gt;&amp;lt;/small&amp;gt;&amp;#039;, refreshLink)&lt;br /&gt;
	end&lt;br /&gt;
	return text .. refreshLink&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Hefner</name></author>
	</entry>
</feed>