Module:Date Erache

De WikiField
Sauter à la navigation Sauter à la recherche

La documentation pour ce module peut être créée à Module:Date Erache/doc

local p = {}

function p.dateErache()
	
	local year = os.date("%Y")
	local month = os.date("%m")
	local day = os.date("%d")
	local hour = os.date("%H")
	-- mw.log(year .. " " .. month .. " " .. day .. " " .. hour)
	
	-- Day 1 of Erache's calendar 
	local dateOrigin = os.time{year=2010, month=11, day=9, hour = 0}
	-- Today
	local dateNow = os.time{year=year,month=month,day=day,hour=hour}
	-- Diff in IRL s
	local diff = dateNow - dateOrigin
	-- Diff in IRL days
	local diffDays = diff / (3600*24)
	
--	mw.log("Original day is : " .. dateOrigin)
--	mw.log("Today is : " .. dateNow )
--	mw.log("Diff is : " .. diff .. " s")
--	mw.log("Diff is : ".. diffDays .." days")
	
	local eracheDays = math.floor(diffDays * 72)
	local eracheMonths = math.floor(eracheDays /64)
	local eracheYear = math.floor(eracheDays / 1024)
	
	local eracheMonth = eracheMonths%16+1
	local months = {}
	months[1] = "Pampélune"
	months[2] = "Fifrelune"
	months[3] = "Mimélune"
	months[4] = "Claircelune"
	months[5] = "Mérolia"
	months[6] = "Cidélia"
	months[7] = "Iffélia"
	months[8] = "Lérolia"
	months[9] = "Holevent"
	months[10] = "Agrevent"
	months[11] = "Tercevent"
	months[12] = "Démévent"
	months[13] = "Radévard"
	months[14] = "Tronvard"
	months[15] = "Pénavard"
	months[16] = "Nérévard"
	local eracheMonthName = months[eracheMonth]
	
	local eracheDay = eracheDays%64+1
	
	local daysOfWeek = {}
	daysOfWeek[1] = "Premui"
	daysOfWeek[2] = "Dezui"
	daysOfWeek[3] = "Tressui"
	daysOfWeek[4] = "Khatui"
	daysOfWeek[5] = "Quinui"
	daysOfWeek[6] = "Sizui"
	daysOfWeek[7] = "Sepui"
	daysOfWeek[8] = "Houi"
	local dayOfWeek = eracheDay%7
	local dayOfWeekName = daysOfWeek[dayOfWeek]
	
	-- mw.log("Nous sommes le " .. dayOfWeekName .. " " .. eracheDay .. " " .. eracheMonthName .. " de l'an ".. eracheYear)
	return dayOfWeekName .. " " .. eracheDay .. " " .. eracheMonthName .. " de l'an ".. eracheYear
end

return p