跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
社群首页
帮助
希顶相关网站
希顶社区官网
(原作)希顶翻译器
〇改希顶转写器
希顶模组服务器
搜索
搜索
外观
创建账号
登录
个人工具
创建账号
登录
查看“︁Module:Time”︁的源代码
模块
讨论
English
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
外观
移至侧栏
隐藏
←
Module:Time
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于这些用户组的用户执行:
用户
、storagereadable
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
高级
特殊字符
帮助
希顶字母
标题
2级
3级
4级
5级
格式
插入
拉丁字母
扩展拉丁字母
国际音标
符号
希腊字母
希腊字母扩展
西里尔字母
阿拉伯字母
扩展阿拉伯字母
希伯来字母
孟加拉语字符集
泰米尔数字和符号
泰卢固语字符集
僧伽罗语字符集
梵文字符集
古吉拉特语字符集
泰语字符集
老挝语
高棉语字母
加拿大原住民音节文字
卢恩
Á
á
À
à
Â
â
Ä
ä
Ã
ã
Ǎ
ǎ
Ā
ā
Ă
ă
Ą
ą
Å
å
Ć
ć
Ĉ
ĉ
Ç
ç
Č
č
Ċ
ċ
Đ
đ
Ď
ď
É
é
È
è
Ê
ê
Ë
ë
Ě
ě
Ē
ē
Ĕ
ĕ
Ė
ė
Ę
ę
Ĝ
ĝ
Ģ
ģ
Ğ
ğ
Ġ
ġ
Ĥ
ĥ
Ħ
ħ
Í
í
Ì
ì
Î
î
Ï
ï
Ĩ
ĩ
Ǐ
ǐ
Ī
ī
Ĭ
ĭ
İ
ı
Į
į
Ĵ
ĵ
Ķ
ķ
Ĺ
ĺ
Ļ
ļ
Ľ
ľ
Ł
ł
Ń
ń
Ñ
ñ
Ņ
ņ
Ň
ň
Ó
ó
Ò
ò
Ô
ô
Ö
ö
Õ
õ
Ǒ
ǒ
Ō
ō
Ŏ
ŏ
Ǫ
ǫ
Ő
ő
Ŕ
ŕ
Ŗ
ŗ
Ř
ř
Ś
ś
Ŝ
ŝ
Ş
ş
Š
š
Ș
ș
Ț
ț
Ť
ť
Ú
ú
Ù
ù
Û
û
Ü
ü
Ũ
ũ
Ů
ů
Ǔ
ǔ
Ū
ū
ǖ
ǘ
ǚ
ǜ
Ŭ
ŭ
Ų
ų
Ű
ű
Ŵ
ŵ
Ý
ý
Ŷ
ŷ
Ÿ
ÿ
Ȳ
ȳ
Ź
ź
Ž
ž
Ż
ż
Æ
æ
Ǣ
ǣ
Ø
ø
Œ
œ
ß
Ð
ð
Þ
þ
Ə
ə
格式
链接
标题
列表
文件
讨论
说明
输入内容
输出结果
斜体
''斜体文字''
斜体文字
粗体
'''粗体文字'''
粗体文字
粗斜体
'''''粗斜体文字'''''
粗斜体文字
希顶字母
local module = {} local getArgs = require('Module:Arguments').getArgs -- 改为从分离出的模块调用,注意现在 sunColor 和 sunColor2 的参数需要预先进行 floor 再行传入 local sunColor = require('Module:SunShow').sunColor local sunColor2 = require('Module:SunShow').sunColor2 local cheiColor = require('Module:SunShow').cheiColor local sun49 = require('Module:SunShow').sun49 local tzbiou = 0 -- 特殊时期是否避开某些容易令人误会的色块 local winterDays = require('Module:冬至日期').winterDays local winterSeconds = require('Module:冬至日期').winterSeconds local winterLength = 23000 local firstWinter = 7322 -- 作为历元的冬至在上述数值的第7322号位 local tick = {18, 7, 23, 47, 10, 31, 16, 17, 12, 21, 34, 43, 37, 2, 13, 9, 36, 14, 4, 45, 27, 20, 39, 41, 24, 42, 19, 44, 32, 11, 26, 25, 30, 28, 8, 48, 5, 40, 29, 33, 6, 35, 38, 46, 15, 22, 3, 1} function module.s2d(frame) -- 秒转天,除以86400 local args = getArgs(frame) local x = tonumber(args[1]) return string.format("%.10f",x/86400) end function module.test() local now=os.time() local start=os.time({year=2021,month=9,day=1,hour=3}) local days=(now-start)/86400 local dayint=math.floor(days) local hours=((now-start)%86400)/3600 return dayint..'天'..hours..'小时' end function module.directly() -- 直接获得当前时间 return os.date('%p')..' '..os.date('%c') end function queIa(seconds) local spmin = 56 local minph = 35 local hpd = 14 local dpm = 35 local mpy = 14 local s = seconds % spmin local minutes = math.floor((seconds - s) / spmin + 0.5) local mi = minutes % minph local hours = math.floor((minutes - mi) / minph + 0.5) local h = hours % hpd local days = math.floor((hours - h) / hpd + 0.5) local d = days % dpm local d1 = d + 1 local months = math.floor((days - d) / dpm + 0.5) local m = months % mpy local m1 = m + 1 local y = math.floor((months - m) / mpy + 0.5) local y1 = y if (y1 >= 0) then y1 = y1 + 1 end return string.format("%d年%d月%d日 %02d:%02d:%02d", y1, m1, d1, h, mi, s) end function module.nowQueIa(frame) local args = getArgs(frame) local offset = args[1] if (offset == nil) then offset = 0 else offset = tonumber(offset) end local now = os.time() local start = os.time({year=1900,month=4,day=4,hour=10,min=12,sec=42}) now = now - start if (offset ~= nil) then now = now + offset end return queIa(now) end function module.dateQueIa(frame) local args = getArgs(frame) local y = args[1] local m = args[2] local d = args[3] local h = args[4] local mi = args[5] local s = args[6] local time1 = os.time({year=y,month=m,day=d,hour=h,min=m,sec=s}) local start = os.time({year=1900,month=4,day=4,hour=10,min=12,sec=42}) time1 = time1 - start return queIa(time1) end function module.nowSunTick(frame) local args = getArgs(frame) local color = string.lower(tostring(args[1])) -- 是否显示颜色 local offset = args[2] -- 时间偏移,单位为秒 if (offset == nil) then offset = 0 else offset = tonumber(offset) end local now = os.time() local start = os.time({year=1996,month=1,day=28,hour=0}) now = now - start if (offset ~= nil) then now = now + offset end local clock = (now-43200) % 86400 -- 一天中的时间,单位为秒,正午为零点 local whichTick = math.floor(clock / 1800) + 1 local c = "" -- 如果显示颜色 if (color == "true") then c = sunColor2(math.floor(tick[whichTick]), tzbiou) end return c..gua[tick[whichTick]].."时" end function module.nowDuaenn(frame) local args = getArgs(frame) local display = args[1] -- 显示模式 local offset = args[2] -- 时间偏移,单位为秒 if (offset == nil) then offset = 0 else offset = tonumber(offset) end local now = os.time() local start = os.time({year=1996,month=1,day=28,hour=0}) now = now - start if (offset ~= nil) then now = now + offset end local clock = now % 86400 - 43200 -- 一天中的时间,单位为秒,正午为零点 local duaenn = clock / 400 -- 转化为段 local duint = math.floor(duaenn) -- 段的整数部分 local suennz = (clock - 400 * duint) / 20 -- 舛 local sint = math.floor(suennz) -- 舛的整数部分 local mint = math.floor(clock % 20) -- 秒 local kc = ''; if (string.find(display,'k')~=nil) then kc=' '; end -- 空格与否 if (display==nil) then return duint else if (string.find(display,":")~=nil) then if (string.find(display,"m")~=nil) then return string.format("%+04d%s:%s%02d%s:%s%02d",duint,kc,kc,sint,kc,kc,mint) else return string.format("%+04d%s:%s%02d",duint,kc,kc,sint) end else if (string.find(display,"m")~=nil) then return string.format("%+d%s段%s%02d%s舛%s%02d%s秒",duint,kc,kc,sint,kc,kc,mint,kc) else if (string.find(display,"s")~=nil) then return string.format("%+d%s段%s%02d%s舛",duint,kc,kc,sint,kc) else return string.format("%+d%s段",duint,kc) end end end end end function sunAriCalender(now, color) local start = os.time({year=1996,month=1,day=28,hour=0}) -- 以公历1996年1月28日零时开始算 local days = (now-start) / 86400 local dayint = math.floor(days) local dayfroms = dayint + 1706817 -- 事实上1996年1月28日是太阳易纪元第1,706,817天 local dayFromOne = dayfroms - 49 -- 纪元零点开始过了49天再开始算 local bigCount = math.floor((dayFromOne - 0.5) / 602651) -- 第几个1650年周期(从第0个开始算),1650年周期为602651天 local bigRemain = dayFromOne - 602651 * bigCount local smallCount = math.floor((bigRemain - 0.5) / 4018) -- 第几个11年周期(从第0个开始算),11年周期为4018天 local smallRemain = bigRemain - 4018 * smallCount local smallTotalCheiNum = math.floor((smallRemain + 48.5) / 49) local smallYear = math.floor((smallTotalCheiNum * 11 + 81.5) / 82) local formerCheis = math.floor(((smallYear - 1) * 82 + 0.5) / 11) local dayInYear = smallRemain - formerCheis * 49 local cheiName = {"火","木","光","土","风","水","空","闰"} local cheiN = math.floor((dayInYear + 48.5) / 49) -- 第几契 local dayN = cheiN * 49 - dayInYear local year = bigCount * 1650 + smallCount * 11 + smallYear local dc = "" local cc = "" -- 如果显示颜色 if (color == "true") then dc = sunColor(math.floor(dayN), tzbiou) cc = cheiColor(cheiN) end return year.."年 "..cc..cheiName[cheiN].."契 "..dc..sun49(dayN).."日" end function sunCalender(now, color, timezone) local start = os.time({year=1996,month=1,day=28,hour=0}) -- 以公历1996年1月28日零时开始算 local days = (now-start) / 86400 local dayint = math.floor(days) local dayfroms = dayint + 1706817 -- 事实上1996年1月28日是太阳易纪元第1,706,817天 local i = 0 local wd = winterDays local ws = winterSeconds local bottom = 9750 -- 只取[bottom,top]区间的冬至年份 local top = bottom + 4095 for i=bottom,top do -- 按时区调整冬至相应日期 if (timezone ~= nil) then ws[i] = ws[i] + timezone end while (ws[i]>=86400) do wd[i] = wd[i] + 1 ws[i] = ws[i] - 86400 end while (ws[i]<0) do wd[i] = wd[i] - 1 ws[i] = ws[i] + 86400 end -- 冬至后(含)第二个自然日,为年末自然日 wd[i] = wd[i] + 97 - (wd[i]-1)%49 end local left = bottom --二分查找,左闭 local right = top + 1 --二分查找,右开 local middle = 0 -- 寻找严格小于dayfroms的最后一个冬至 while (right - left > 1) do middle = math.floor((left+right+0.5)/2) --二分中点,向下取整 if (dayfroms <= wd[middle]) then --比middle所在年的冬至要早,不含middle right = middle else --可能比middle所在年要晚,也有可能正好是这一年 left = middle end end --left即为所求年的下标 local year = left - firstWinter + 1 -- 七历年份 local restdays = dayfroms - wd[left] -- 这一年的具体第几天 local cheiName = {"火","木","光","土","风","水","空","闰"} local cheiN = math.floor((restdays + 48.5) / 49) -- 第几契 local dayN = cheiN * 49 - restdays local dc = "" local cc = "" -- 如果显示颜色 if (color == "true") then dc = sunColor(math.floor(dayN), tzbiou) cc = cheiColor(cheiN) end return year.."年 "..cc..cheiName[cheiN].."契 "..dc..sun49(dayN).."日" end function sunDay(now, display, color) local start = os.time({year=1996,month=1,day=28,hour=0}) -- 以公历1996年1月28日零时开始算 local days = (now-start) / 86400 local dayint = math.floor(days) local dayfroms = dayint + 1706817 -- 事实上1996年1月28日是太阳易纪元第1,706,817天 local phase = (-dayfroms) % (49*49*49*49) local d = phase % 49 -- 日 local s = math.floor(phase/(49)+0.00000000001) % 49 -- 季 local t = math.floor(phase/(49*49)+0.00000000001) % 49 -- 轮 local p = math.floor(phase/(49*49*49)+0.0000000000001) -- 朝 local dc = "" local sc = "" local tc = "" local pc = "" -- 如果显示颜色 if (color == "true") then dc = sunColor(math.floor(d), tzbiou) sc = sunColor(math.floor(s), tzbiou) tc = sunColor(math.floor(t), tzbiou) pc = sunColor(math.floor(p), tzbiou) end if (display=='1') then return dc..sun49(d).."日" else if (display=='2') then return sc..sun49(s).."季 "..dc..sun49(d).."日" else if (display=='3') then return tc..sun49(t).."轮 "..sc..sun49(s).."季 "..dc..sun49(d).."日" else return pc..sun49(p).."朝 "..tc..sun49(t).."轮 "..sc..sun49(s).."季 "..dc..sun49(d).."日" end end end end function module.nowSunCalender(frame) local args = getArgs(frame) local color = string.lower(tostring(args[1])) -- 是否显示颜色 local timezone = args[2] -- 时区,【相对于东八区】,单位为【秒】,注意! local offset = args[3] -- 时间偏移,单位为天 if (timezone == nil) then timezone = 0 else timezone = tonumber(timezone) end if (offset == nil) then offset = 0 else offset = tonumber(offset) end local now = os.time() if (offset ~= nil) then now = now + offset * 86400 end if (timezone ~= nil) then now = now + timezone end return sunCalender(now, color, timezone) end function module.dateSunCalender(frame) local args = getArgs(frame) local y = tonumber(args[1]) local m = tonumber(args[2]) local d = tonumber(args[3]) local color = string.lower(tostring(args[4])) -- 是否显示颜色 local timezone = args[5] -- 时区,【相对于东八区】,单位为【秒】,注意! if (timezone == nil) then timezone = 0 else timezone = tonumber(timezone) end local date = os.time({year=y,month=m,day=d}) if (timezone ~= nil) then date = date + timezone end return sunCalender(date, color, timezone) end function module.nowSunAriCalender(frame) local args = getArgs(frame) local color = string.lower(tostring(args[1])) -- 是否显示颜色 local timezone = args[2] -- 时区,【相对于东八区】,单位为【秒】,注意! local offset = args[3] -- 时间偏移,单位为天 if (timezone == nil) then timezone = 0 else timezone = tonumber(timezone) end if (offset == nil) then offset = 0 else offset = tonumber(offset) end local now = os.time() if (offset ~= nil) then now = now + offset * 86400 end if (timezone ~= nil) then now = now + timezone end return sunAriCalender(now, color) end function module.dateSunAriCalender(frame) local args = getArgs(frame) local y = tonumber(args[1]) local m = tonumber(args[2]) local d = tonumber(args[3]) local color = string.lower(tostring(args[4])) -- 是否显示颜色 local timezone = args[5] -- 时区,【相对于东八区】,单位为【秒】,注意! if (timezone == nil) then timezone = 0 else timezone = tonumber(timezone) end local date = os.time({year=y,month=m,day=d}) if (timezone ~= nil) then date = date + timezone end return sunAriCalender(date, color) end function module.nowSunDay(frame) local args = getArgs(frame) local display = args[1] -- 显示长度 local color = string.lower(tostring(args[2])) -- 是否显示颜色 local offset = args[3] -- 时间偏移,单位为天 if (offset == nil) then offset = 0 else offset = tonumber(offset) end local now = os.time() if (offset ~= nil) then now = now + offset * 86400 end return sunDay(now, display, color) end function module.dateSunDay(frame) local args = getArgs(frame) local y = tonumber(args[1]) local m = tonumber(args[2]) local d = tonumber(args[3]) local display = args[4] -- 显示长度 local color = string.lower(tostring(args[5])) -- 是否显示颜色 local now = os.time({year=y,month=m,day=d}) return sunDay(now, display, color) end function module.latinTime(frame) local args = getArgs(frame) local offset = args[1] -- 时间偏移,单位为时 local month = {"Jeneiro", "Fabruario", "Marco", "Abrile", "Maio", "Jugno", "Julio", "Agosto", "Setembre", "Oktubre", "Novembre", "Decembre"} -- 1至12月 local weekday = {"Lunde", "Marde", "Merkrede", "Jeude", "Vendrede", "Sabado", "Domingo"} -- 周一至周日 local now = os.time() - 3600 * 8 if (offset ~= nil) then if (tonumber(offset)~=nil) then now = now + offset * 3600 end end return os.date("%X\n",now)..weekday[7-((7-tonumber(os.date("%w",now)))%7)]..os.date(", %d ",now)..month[tonumber(os.date("%m",now))]..os.date(" %Y",now) end function module.NorasiaTime(frame) local args = getArgs(frame) local offset = args[1] -- 时间偏移,单位为时 local month = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"} -- 1至12月 local weekday = {"月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜日"} -- 周一至周日 local now = os.time() - 3600 * 8 if (offset ~= nil) then if (tonumber(offset)~=nil) then now = now + offset * 3600 end end return os.date("%X\n",now)..os.date(" %Y年 ",now)..month[tonumber(os.date("%m",now))]..os.date("%d日 ",now)..weekday[7-((7-tonumber(os.date("%w",now)))%7)] end function stringAt(str, pos) return string.sub(str, pos, pos) end function HetesflusYear(year) year = year - 1326 return stringAt('eDcszywhAaoiu', year % 13 + 1) .. stringAt('tbpmfvd', year % 7 + 1) .. stringAt('ZnlrgkNxjqS', year % 11 + 1) end function module.HetesflusTime(frame) local args = getArgs(frame) local offset = args[1] local now = os.time() if (offset ~= nil and tonumber(offset) ~= nil) then now = now + offset * 3600 end local dayOfYear = tonumber(os.date('%j', now)) local year = tonumber(os.date('%Y', now)) local month = 1 local sum = -11 local days = {30, 30, 30, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30} if year % 4 == 0 and (year % 100 ~= 0 or year % 400 == 0) then days[3] = 31 end while sum + days[month] < dayOfYear do sum = sum + days[month] month = month + 1 end if month < 4 then year = year - 1 end local monthName = {'冬', '寒', '花', '春', '收', '祭', '夏', '航', '酒', '秋', '種', '雨', '冬'} return '<samp>' .. HetesflusYear(year) .. '</samp>年' .. monthName[month] .. '月' .. (dayOfYear - sum) .. '日' end return module
调试控制台
* 此模块的返回的值存于控制台变量“p”中,包括没有保存的变更。 * 在一行的前面加上“=”可以将其作为表达式来计算或使用print()显示。显示表格请使用mw.logObject()。 * 在模块代码中使用mw.log()和mw.logObject()来向控制台发送消息。
该页面使用的模板:
Module:Time/doc
(
查看源代码
)
返回
Module:Time
。