Module:Time:修订间差异

此后如竟没有炬火,我便是唯一的光。
跳转到导航 跳转到搜索
无编辑摘要
无编辑摘要
第30行: 第30行:
local args = getArgs(frame)
local args = getArgs(frame)
local display = args[1]
local display = args[1]
local color = string.lower(args[2])
local color = string.lower(tostring(args[2]))
local now = os.time()
local now = os.time()
local start = os.time({year=1996,month=1,day=28,hour=0})
local start = os.time({year=1996,month=1,day=28,hour=0})

2021年9月8日 (三) 13:22的版本

可在Module:Time/doc创建此模块的帮助文档

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

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 sunColor(inp)
	local rainbow = {"#f4592d", "#eda667", "#faf03e", "#5fb319", "#8eede2", "#0568e3","#49207c"}
	local l = inp % 7
	local u = math.floor(inp/7+0.125) % 7
	return '<span style="background:-webkit-linear-gradient(90deg, '..rainbow[7-l]..' 0%, '..rainbow[7-l]..' 50%, '..rainbow[7-u]..' 50%, '..rainbow[7-u]..' 100%)"> </span>'
end

function sun49(inp)
	local gua = {"火", "祭祀", "对手", "成败", "反叛", "救赎", "爆发", "欲望", "木", "创造", "新生", "凋谢", "重生", "弥散", "自我", "寻找", "存在", "经典", "革新", "梦幻", "倾听", "忍耐", "腐朽", "绝笔", "地", "孤独", "小人", "永恒", "恶魔", "盛开", "理解", "泥土", "风", "雾气", "神", "对抗", "绽放", "思考", "同伴", "变幻", "水", "隐退", "超越", "生命", "表达", "破碎", "时间", "朦胧", "自然"}
	return gua[49-(inp%49)]
end

function module.nowSunDay(frame)
	local args = getArgs(frame)
	local display = args[1]
	local color = string.lower(tostring(args[2]))
	local now = os.time()
	local start = os.time({year=1996,month=1,day=28,hour=0})
	local days = (now-start) / 86400
	local dayint = math.floor(days)
	local dayfroms = dayint + 1706817
	local phase = (-dayfroms) % (49*49*49*49)
	local d = phase % 49
	local s = math.floor(phase/(49)+0.125) % 49
	local t = math.floor(phase/(49*49)+0.125) % 49
	local p = math.floor(phase/(49*49*49)+0.125)
	local dc = ""
	local sc = ""
	local tc = ""
	local pc = ""
	if (color == "true") then
		dc = sunColor(d)
		sc = sunColor(s)
		tc = sunColor(t)
		pc = sunColor(p)
	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

return module