Jump to content

Module:Unsigned

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Σ (talk | contribs) at 20:01, 7 December 2013 (For {{Template:Unsigned}}). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

-- There's probably a way to use strptime or some other more sophisticated way, but you're not supposed to be using a non-timestamp as input anyway.

function string.endswith(String,End)
	return End=='' or string.sub(String,-string.len(End))==End
end

function addUtcToStringIfItDoesNotEndWithUtc(s)
	if not s:endswith("(UTC)") then
		return s .. " (UTC)"
	end
	return s
end

function p.main(frame)
	local args = frame.args
	local hopefullyTimestamp = args[1] or os.date('%H:%M, %d %B %Y (%Z)')
	return addUtcToStringIfItDoesNotEndWithUtc(hopefullyTimestamp)
end

return p