模块:Date0
此模块的文档可以在模块:Date0/doc创建
local p = {}
local getArgs = require("Module:Arguments").getArgs
function p._date0(frame, args)
local y, m, d = "", "", ""
local zero = '<span style="speak: none; visibility: hidden; color: transparent;">0</span>'
local _y, _m, _d = args[1] or "", args[2] or "", args[3] or ""
_y = mw.ustring.gsub(_y, "^0", "")
_m = mw.ustring.gsub(_m, "^0", "")
_d = mw.ustring.gsub(_d, "^0", "")
if mw.ustring.find(_y, "^%d%d?%d?%d?$") then
y = mw.ustring.rep(zero, 4 - mw.ustring.len(_y)) .. _y .. "年"
end
if mw.ustring.find(_m, "^[01]?%d$") then
m = (mw.ustring.len(_m) == 1 and zero or "") .. _m .. "月"
elseif _m == "++" or _m == "+" then
m = "春季预定"
elseif _m == "--" or _m == "-" then
m = "夏季预定"
elseif _m == "**" or _m == "*" then
m = "秋季预定"
elseif _m == "//" or _m == "/" then
m = "冬季预定"
elseif _m == ".." or _m == "." then
m = "年内预定"
elseif _m == "Q1" then
m = "第一季度"
elseif _m == "Q2" then
m = "第二季度"
elseif _m == "Q3" then
m = "第三季度"
elseif _m == "Q4" then
m = "第四季度"
elseif _m == "?" or _m == "??" then
m = '<span style="speak: none; visibility: hidden; color: transparent;">??月</span>'
else
m = _m
end
if mw.ustring.find(_d, "^[0-3]?%d$") then
d = (mw.ustring.len(_d) == 1 and zero or "") .. _d .. "日"
elseif (_d == "?" or _d == "??") or ((_m == "?" or _m == "??") and (_d == "")) then
d = '<span style="speak: none; visibility: hidden; color: transparent;">??日</span>'
else
d = _d
end
return y .. m .. d
end
function p.date0(frame)
return p._date0(frame, getArgs(frame))
end
return p