モジュール:サンドボックス/cpro/datetime
表示
モジュールの解説[作成]
local lang = mw.language.getContentLanguage()
local Date = {}
Date.now = function()
return Date.new(os.time())
end
Date.parse = function(dateString)
return Date.new(tonumber(lang:formatDate('U', dateString)))
end
Date.new = function(unixTimestamp)
local obj = {}
obj.__time = unixTimestamp
obj.__t = os.date('*t', obj.__time)
obj.year = function(self)
return self.__t.year
end
obj.day = function(self)
return self.__t.day
end
obj.julianDay = function(self)
return self.__time / 86400 + 2440587.5
end
return obj
end
--interface
local p = {}
p.JDLite = function(frame)
local d = Date.parse(frame.args[1])
mw.log(d:year())
mw.log(d:day())
return d:julianDay()
end
return p