Module:Agência Brasil

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Lua

CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules


Helper module for {{Agência Brasil}}


Code

require('strict')

-- ==================================================
-- === External functions ===========================
-- ==================================================
local p = {}

-- ===========================================================================
-- === Versions of the function to be called from template namespace
-- ===========================================================================
function p.main(frame)
	if frame.args[1] then
		local date2jdn = require('Module:Calendar')._date2jdn
		local jdn = date2jdn(frame.args[1], 1)
		if (not jdn) then
			return 0
		elseif (jdn>=2451953 and jdn<=2453919) then -- 2001-02-12 - 2006-07-02
			return 1
		elseif (jdn>=2453962 and jdn<=2455679) then -- 2006-08-14 - 2011-04-27
			return 2
		elseif (jdn>=2455681 and jdn<=2457808) then -- 2011-04-29 - 2017-02-23
			return 3
		elseif (jdn> 2457808)                  then -- 2017-02-23
			return 4
		end
	else
		return 0
	end
end

return p