La documentación pa esti módulu pue crease en Módulu:Data/usu

local p = {}

local mes_num = {
	['jan'] = 1, ['xin'] = 1,
	['feb'] = 2,
	['mar'] = 3,
	['apr'] = 4, ['abr'] = 4,
	['may'] = 5,
	['jun'] = 6, ['xun'] = 6,
	['jul'] = 7, ['xnt'] = 7,
	['aug'] = 8, ['ago'] = 8,
	['sep'] = 9, ['set'] = 9,
	['oct'] = 10, ['och'] = 10,
	['nov'] = 11, ['pay'] = 11,
	['dec'] = 12,  ['avi'] = 12 
	}

local function f(...)
	return mw.language.new('ast'):formatDate(...)
end

function p.data_format(data, formata)
	if type(data) == "table" then -- dende plantíes via invoke o dende módulos via require
		formata = data.args[2]
		data = require('Module:Delink')._delink(data.args)
	end
	if formata == '' then formata = nil end
	
	-- sin preposiciones
	data = string.gsub(data, " de ", " ")
	data = string.gsub(data, " d'", " ")
	
	dataparts = mw.text.split(data, "[-/. ]")
	if #dataparts == 3 then
		part1 = tonumber(dataparts[1])
		part2 = tonumber(dataparts[2])
		part3 = tonumber(dataparts[3])
		if part1 and part2 and part3 then
			if part1 > 31 then -- format a m d
				any = part1
				mes = part2
				dia = part3
			elseif part2 > 12 then -- format m d a
				mes = part1
				dia = part2
				any = part3
			else -- format d m a
				dia = part1
				mes = part2
				any = part3
			end
		else -- format d mes a
			mes_abr = string.lower(string.sub(dataparts[2], 1, 3))
			mes = mes_num[mes_abr]
			dia = part1
			any = part3
		end
		
		if dia and mes and any and type(dia) == 'number' and type(mes) == 'number' and type(any) == 'number' then
			datastr = dia .. '-' .. mes .. '-' .. any
			if formata == nil or formata == 'consulta' then
				formata = 'j F Y'
			end
			local success, data = pcall(f, formata, datastr)
			if success then
				return data
			else
				return "<span style='color:red; font-weight:bold; font-style:italic'>Data incorreuta</span>[[Categoría:Páxines con error de referencies pa les dates]]"
			end
		end
	end
	
	return data
end

return p