モジュール:カレンダー
ナビゲーションに移動
検索に移動
このモジュールについての説明文ページを モジュール:カレンダー/doc に作成できます
local p = {}
local function getTable(frame)
yogurian = require("モジュール:ヨーグレキ")
ar = {string.match(frame.args[1], "(%d+)%-(%d+)%-(%d+)")}
if ar[1] == nil then
year = tonumber(frame.args[1])
month = tonumber(frame.args[2])
day = tonumber(frame.args[3])
else
year = tonumber(ar[1])
month = tonumber(ar[2])
day = tonumber(ar[3])
end
yogurian.checkYogurianValidDate(year,month,day)
days = month == 1 and (yogurian.isLeap(year + 2020) and 36 or 35) or 30
beforeDays = month == 2 and (yogurian.isLeap(year + 2020) and 36 or 35) or 30
res = "{| class=\"wikitable\" style=\"text-align:center;color:red;" .. (frame.args[4] ~= nil and frame.args[4] or "width:70%;height:auto;font-size:200%;") .. "\"\n"
.."|+ style=\"color:black\" | ".. month .."月\n"
.."|- style=\"background-color:red;color:white;font-weight:bold;\"\n"
.."| W || I || K || ゐ || 黃 || ヰ || 来"
gregorianDate = yogurian.yogurianToGregorianL(year,month,1)
doWeek = os.date("%w",os.time({day=gregorianDate[3],month=gregorianDate[2],year=gregorianDate[1]})) + 1
doWeek = doWeek > 6 and 0 or doWeek
m = month - 1
d = beforeDays - doWeek + 1
for i = 1,42 do
res = res .. ((i % 7 == 1) and "\n|-\n| " or "|| ")
if (m == month - 1 and d > beforeDays) then
d = 1
m = month
end
if (m == month and d > days) then
d = 1
m = month + 1
end
res = res .. (m ~= month and "style=\"color:#fbb\" | " or "")
res = res .. ((m == month and d == day) and "style=\"background-color:yellow\" | " .. d or d) .. " "
d = d + 1
end
return res.."\n|}"
end
p.getTable = getTable
return p