跳转到内容

模組:Chinese date

被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由Where was I last night?留言 | 贡献2016年12月10日 (六) 16:09编辑。这可能和当前版本存在着巨大的差异。

require('Module:No globals')

local getArgs = require('Module:Arguments').getArgs
local p = {}

local function toChineseDate(format, date)
	return mw.getCurrentFrame():callParserFunction('#time', format, date)
end

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	-- Main module code goes here.
	local date, suffix = require('Module:ISODate').dateAndSuffix(args[1])
	if string.match(date, '^%d+%-%d%d%-%d%d$') then
		return toChineseDate('Y年Mj日', date) .. (args.suf and suffix or '')
	end
	if string.match(date, '^%d+%-%d%d$') then
		return toChineseDate('Y年M', date) .. (args.suf and suffix or '')
	end
	if string.match(date, '^%d+$') then
		return toChineseDate('Y年', date) .. (args.suf and suffix or '')
	end

	return date .. (args.suf and suffix or '')
end

return p