RuneScape Wiki
Registre-se
Advertisement

A documentação para este módulo pode ser criada na página Módulo:DiaRS/doc

local p = {}
 
local hc = require('Módulo:Paramtest').has_content
local yn = require('Módulo:Yesno')
 
function p.main(frame)
	local args = frame:getParent().args
	local lang = mw.getContentLanguage()
 
	local z,l
	if hc(args[1]) then
	    -- Convert months to english variant
	    -- lang:formatDate() does not seem to acept 'pt'
		args[1] = args[1]:gsub("de ", "")
		args[1] = args[1]:gsub("janeiro", "January")
		args[1] = args[1]:gsub("fevereiro", "February")
		args[1] = args[1]:gsub("março", "March")
		args[1] = args[1]:gsub("abril", "April")
		args[1] = args[1]:gsub("maio", "May")
		args[1] = args[1]:gsub("junho", "June")
		args[1] = args[1]:gsub("julho", "July")
		args[1] = args[1]:gsub("agosto", "August")
		args[1] = args[1]:gsub("setembro", "September")
		args[1] = args[1]:gsub("outubro", "October")
		args[1] = args[1]:gsub("novembro", "November")
		args[1] = args[1]:gsub("dezembro", "December")
		
		z = lang:formatDate('z', args[1])
		l = lang:formatDate('L', args[1])
	else
		z = lang:formatDate('z')
		l = lang:formatDate('L')
	end
 
	local rs = p._main(z, l)
 
	if yn(args.nolink, false) then
		return rs
	else
		return string.format('[[Calendário|%s]]', rs)
	end
end
 
-- calculation/module entry point
-- params
--		z	day of the year (jan 1 = 0) ({{#time:z}})
--		l	1 if a leap year, 0 otherwise ({{#time:L}})
--	both identical to #time parser function usage, use mw.language:formatDate, as above
-- output
--		string of the current RuneScape day, per [[Calendar]]
 
function p._main(z, l)
	z = tonumber(z)
	l = tonumber(l)
	-- Rintra: 1 Jan - 8 Feb; z=0..38
	if z < 39 then
		return (z+1) .. ' de Rintra'
	elseif z < 59 then
		-- Moevyng: 9 Feb - 18 Mar, leap day in the middle
		-- split: 9-28 Feb; z=39..58
		return (z+1 -39) .. ' de Moevin'
	elseif l == 1 and z == 59 then
		-- Moevyng day: 29 Feb
		return 'Dia de Moevin'
	end
	-- now we can remove the leap day from z
	z = z - l
	if z < 77 then
		-- Moevyng part 2: 1-18 Mar; z=59..76
		return (z+1 -39) .. ' de Moevin'
	elseif z < 109 then
		-- Bennath: 19 Mar - 19 Apr; z=77..108
		return (z+1 - 77) .. ' de Beatus'
	elseif z < 143 then
		-- Raktuber: 20 Apr - 23 May; z=109-142
		return (z+1 - 109) .. ' de Raktuber'
	elseif z < 181 then
		-- Pentember: 24 May - 30 Jun; z=143..180
		return (z+1 - 143) .. ' de Pentembro'
	elseif z < 212 then
		-- Fentuary: 1 Jul - 31 Jul; z=181..211
		return (z+1 - 181) .. ' de Fentueiro'
	elseif z < 250 then
		-- Septober: 1 Aug - 7 Sep; z=212..249
		return (z+1 - 212) .. ' de Septobro'
	elseif z < 290 then
		-- Ire of Phyrrys: 8 Sep - 17 Oct; z=250..289
		return (z+1 - 250) .. ' de Ira de Phyrris'
	elseif z < 329 then
		-- Novtumber: 18 Oct - 25 Nov; z=290..328
		return (z+1 - 290) .. ' de Novubro'
	elseif z < 365 then
		-- Wintumber: 26 Nov - 31 Dec; z=329..364
		return (z+1 - 329) .. ' de Invernubro'
	end
	return "''?''"
end
 
 
return p
Advertisement