Modulo:Data/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
+classe Date
+getDateString
Riga 59:
local function date_lt(t, t2)
return t.ut < t2.ut
end
 
local function date_tostring(t)
return mw.getContentLanguage():formatDate('j F Y', '@' .. t.ut)
end
 
function Date:new(str)
local self = {}
setmetatable(self, { __index = Date, __eq = date_eq, __lt = date_lt, __tostring = date_tostring })
self.ut = tonumber(mw.getContentLanguage():formatDate('U', str, true))
return self
end
 
function Date:getDateString()
return (mw.getContentLanguage():formatDate('j F Y', '@' .. tself.ut):gsub('^1%s', '1º '))
end
 
function Date:addDays(days)
self.utreturn =Date:new('@' .. (self.ut + days * 86400))
end