მოდული:კალენდარი
იერსახე
შეგიძლიათ შექმნათ დოკუმენტაცია ამ მოდულისათვის: მოდული:კალენდარი/ინფო
require('Module:No globals')
local p = {}
local root = {}
local function addRow(row)
table.insert(root, row)
end
local function getMonthNameInGeorgian(month)
return ({"ღურთუთა","ფურთუთა","მელახი","პირელი","მესი","მანგი","კვირკვე","მარაშინათუთა","ეკენია","გჷმათუთა","გერგობათუთა","ქირსეთუთა"})[month]
end
local function isLeapYear(year)
return year % 4 == 0 and (year % 100 ~= 0 or year % 400 == 0)
end
local function getDaysInMonth(month, year)
return month == 2 and isLeapYear(year) and 29
or ("\31\28\31\30\31\30\31\31\30\31\30\31"):byte(month)
end
function p.main(frame)
local year = tonumber(frame.args.year)
local month = tonumber(frame.args.month)
local headerColor = (frame.args.headerColor and frame.args.headerColor ~= "") and frame.args.headerColor or "#C0C0C0"
local color = (frame.args.color and frame.args.color ~= "") and frame.args.color or "#DCDCDC"
local firstWeekday = tonumber(os.date("%w",os.time{year=year, month=month, day=1}))
local monthName = getMonthNameInGeorgian(month)
local prevMonthName = getMonthNameInGeorgian((month - 2) % 12 + 1)
local nextMonthName = getMonthNameInGeorgian(month % 12 + 1)
local daysInMonth = getDaysInMonth(month, year)
addRow("{| class=\"infobox\" style=\"float:right; margin-left: 1em; text-align:center;\" cellpadding=2 cellspacing=0\n")
addRow("|- style=\"background:" .. headerColor .. ";\"\n")
addRow("|align=center| [[" .. prevMonthName .. "| << ]]\n")
addRow("|colspan=\"5\"|'''[[" .. monthName .. "]]'''\n")
addRow("|align=center| [[" .. nextMonthName .. "| >> ]]\n")
addRow("|- style=\"background:" .. color .. ";\"\n")
addRow("|width=\"14%\"|ორშ\n")
addRow("|width=\"14%\"|სამ\n")
addRow("|width=\"14%\"|ოთხ\n")
addRow("|width=\"14%\"|ხუთ\n")
addRow("|width=\"14%\"|პარ\n")
addRow("|width=\"14%\"|შაბ\n")
addRow("|width=\"14%\"|კვი\n")
addRow("|-\n")
for i = 1, (firstWeekday - 1) % 7 do
addRow("|\n")
end
for i = 1, daysInMonth do
addRow("|[[" .. i .. " " .. monthName .. "|" .. i .. "]]\n")
addRow(((i + firstWeekday - 1) % 7 == 0 and "|-\n" or ""))
end
addRow("|- style=\"background:" .. color .. ";\"\n")
addRow("|colspan=\"7\"|'''[[" .. year .. "]]'''\n")
addRow("|}")
return table.concat(root)
end
return p