跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
快速跳转
快速上手
登场角色
歌曲列表
成就指南
任务指南
DLC购买指南
其他企划
CDC赛事
DJMAX Ent
DJMAX中文资料库
搜索
搜索
外观
外观
移至侧栏
隐藏
创建账号
登录
个人工具
创建账号
登录
查看“︁模块:Countdown”︁的源代码
模块
讨论
English
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
←
模块:Countdown
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} -- Constants local lang = mw.language.getContentLanguage() local getArgs = require('Module:Arguments').getArgs local function formatMessage(secondsLeft, event, color) local timeLeft = lang:formatDuration(secondsLeft, {'years', 'weeks', 'days', 'hours', 'minutes', 'seconds'}) -- Color and bold the numbers, because it makes them look important. timeLeft = string.gsub(timeLeft, '(%d+)', '<span style="color: ' .. (color or '#000') .. '; font-weight: bold;">%1</span>') return string. Format('%s', timeLeft) end function p.main(frame) local args = getArgs(frame) if not (args.year and args.month and args.day) then return '<strong class="error">错误:需指定年、月、日。</strong>' end local timeArgs = {year=args.year, month=args.month, day=args.day, hour=args.hour, min=args.minute, sec=args.second} for k,v in pairs(timeArgs) do if not tonumber(v) then error('Argument ' .. k .. ' could not be parsed as a number: ' .. v) end end local eventTime = os.time(timeArgs) local timeToStart = os.difftime(eventTime, os.time()) -- (future time - current time) local text if timeToStart > 0 then -- Event has not begun yet text = formatMessage(timeToStart, args.event or '事件开始', args.color) elseif args.duration then local timeToEnd if args['duration unit'] then -- Duration is in unit other than seconds, use formatDate to add timeToEnd = tonumber(lang:formatDate('U', '@' .. tostring(timeToStart) .. ' +' .. tostring(args.duration) .. ' ' .. args['duration unit'])) else timeToEnd = timeToStart + (tonumber(args.duration) or error('args.duration should be a number of seconds', 0)) end if timeToEnd > 0 then -- Event is in progress text = args.eventstart or formatMessage(timeToEnd, args.color) else -- Event had a duration and has now ended text = args.eventend or ((lang:ucfirst(args.event or '事件')) .. ' 已结束。') end else -- Event had no duration and has begun text = args.eventstart or ((lang:ucfirst(args.event or '事件')) .. ' 已开始。') end local refreshLink if args.refresh == 'no' then refreshLink = '' else refreshLink = mw.title.getCurrentTitle():fullUrl({action = 'purge'}) refreshLink = string.format(' <small><span class="plainlinks">([%s 刷新])</span></small>', refreshLink) end return text .. refreshLink end return p
该页面使用的模板:
模块:Countdown/doc
(
查看源代码
)
返回
模块:Countdown
。
搜索
搜索
查看“︁模块:Countdown”︁的源代码
添加话题