跳转到内容
打开/关闭搜索
搜索
打开/关闭菜单
397
文件
1979
用户
1.2万
编辑
Gal中文百科
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
在其他项目中
打开/关闭外观设置菜单
无法加载偏好设置。请检查您的网络连接并重试。
重试
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
讨论
贡献
创建账号
登录
编辑“︁
Module
:
Hms
”︁
来自Gal中文百科
查看
阅读
编辑源代码
查看历史
associated-pages
模块
讨论
更多操作
更多
工具
链入页面
相关更改
页面信息
警告:
您没有登录。如果您进行任何编辑,您的IP地址会公开展示。如果您
登录
或
创建账号
,您的编辑会以您的用户名署名,此外还有其他益处。
反垃圾检查。
不要
加入这个!
local p = {} function p._error( error_str ) return '[[Category:输入值出现错误的持续时间]]<strong class="error">错误:' .. error_str .. '</strong>' end function p.main(frame) local args = require('Module:Arguments').getArgs(frame, {wrappers = {'Template:Duration', 'Template:Duration/sandbox'}}) local tmp = args.duration or args[1] or '' local duration = {} if tonumber(args[1]) or args[2] or args[3] then if args[4] then return p._error('不应指定参数4') end if not args[1] or args[1] == '' then duration = {args[2] or 0, args[3] or 0} else duration = {args[1], args[2] or 0, args[3] or 0} end tmp = nil for k, v in ipairs(duration) do duration[k] = tonumber(v) if not duration[k] then return p._error('无效的值') end end elseif args.h or args.m or args.s then if not args.h or args.h == '' then duration = {args.m or 0, args.s or 0} else duration = {args.h, args.m or 0, args.s or 0} end tmp = nil for k, v in ipairs(duration) do duration[k] = tonumber(v) if not duration[k] then return p._error('无效的值') end end else if mw.ustring.find(tmp, 'class="duration"', 1, yes) then return tmp end -- if there is already a microformat, don't do anything duration = mw.text.split(mw.ustring.match(tmp, '%d*:?%d+:%d+%.?%d*') or '', ':') -- split into table if duration[4] then return p._error('不能超过两个冒号') end for k, v in ipairs(duration) do duration[k] = tonumber(v) or 0 end -- convert values to numbers end if duration[3] then if (duration[1] + duration[2] + duration[3]) == 0 then return nil end if (duration[1] ~= math.ceil(duration[1])) or (duration[2] ~= math.ceil(duration[2])) then return p._error('小时数和分钟数必须是整数') end if duration[3] >= 60 then return p._error('秒数不能大于59') end if duration[2] >= 60 then return p._error('当小时数存在时,分钟数不能大于59') end if duration[2] < 10 then duration[2] = '0'..duration[2] end -- zero padding if duration[3] < 10 then duration[3] = '0'..duration[3] end duration = '<span class="duration"><span class="h">' .. duration[1] .. '</span>:<span class="min">' .. duration[2] .. '</span>:<span class="s">' .. duration[3] .. '</span></span>' elseif duration[2] then if (duration[1] + duration[2]) == 0 then return nil end if duration[1] ~= math.ceil(duration[1]) then return p._error('小时数和分钟数必须是整数') end if duration[2] >= 60 then return p._error('秒数不能大于59') end if duration[2] < 10 then duration[2] = '0'..duration[2] end -- zero padding duration = '<span class="duration"><span class="min">' .. duration[1] .. '</span>:<span class="s">' .. duration[2] .. '</span></span>' else duration = '' end if tmp and tmp ~= '' then if duration ~= '' then tmp = mw.ustring.gsub(tmp, '%d*:?%d+:%d+%.?%d*', duration, 1) else tmp = tmp .. ' [[Category:不含hAudio微格式的持续时间]]' end else if duration ~= '' then tmp = duration end end return tmp end return p
摘要:
请注意,所有对Gal中文百科的贡献均可能会被其他贡献者编辑、修改或删除。如果您不希望您的文字作品被随意编辑,请不要在此提交。
您同时也向我们承诺,您提交的内容为您自己所创作,或是复制自公共领域或类似自由来源(详情请见
Gal中文百科:著作权
)。
未经许可,请勿提交受著作权保护的作品!
取消
编辑帮助
(在新窗口中打开)
此页面嵌入的页面:
Module:Hms/doc
(
编辑
)
编辑“︁
Module
:
Hms
”︁
来自Gal中文百科