მოდული:კალენდარი: განსხვავება გადახედვებს შორის

არ არის რედაქტირების რეზიუმე
 
local p = {}
local root = {}
 
local function addRow(row)
table.insert(root, row)
end
 
local function getMonthNameInGeorgian(month)
return ({"იანვარი","თებერვალი","მარტი","აპრილი","მაისი","ივნისი","ივლისი","აგვისტო","სექტემბერი","ოქტომბერი","ნოემბერი","დეკემბერი"})[month]
end;
 
local function isLeapYear(year)
local year = tonumber(frame.args.year)
local month = tonumber(frame.args.month)
local headerColor = (frame.args.headerColor) and frame.args.headerColor or "#C0C0C0"
local color = (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)
res local = res ..prevMonthName "|align=center| [[" .. getMonthNameInGeorgian((month - 2) % 12 + 1) .. "| << ]]\n"
res local = res ..nextMonthName "|align=center| [[" .. getMonthNameInGeorgian(month % 12 + 1) .. "| << ]]\n"
local daysInMonth = getDaysInMonth(month, year)
local res = addRow("{| class=\"infobox\" style=\"float:right; margin-left: 1em; text-align:center;\" cellpadding=2 cellspacing=0\n")
res = res .. addRow("|- style=\"background:#C0C0C0" .. headerColor .. ";\"\n")
addRow("|align=center| [[" .. prevMonthName .. "| << ]]\n")
res = res .. addRow("|colspan=\"5\"|'''[[" .. monthName .. "]]'''\n")
addRow("|align=center| [[" .. nextMonthName .. "| >> ]]\n")
res = res .. addRow("|- style=\"background:#DCDCDC" .. color .. ";\"\n")
res = res .. addRow("|width=\"14%\"|ორშ\n")
res = res .. addRow("|width=\"14%\"|სამ\n")
res = res .. addRow("|width=\"14%\"|ოთხ\n")
res = res .. addRow("|width=\"14%\"|ხუთ\n")
res = res .. addRow("|width=\"14%\"|პარ\n")
res = res .. addRow("|width=\"14%\"|შაბ\n")
res = res .. addRow("|width=\"14%\"|კვი\n")
addRow("|-\n")
 
for i = 1, firstWeekday - 1 do
local res = "{| class=\"infobox\" style=\"float:right; margin-left: 1em; text-align:center;\" cellpadding=2 cellspacing=0\n"
addRow("|\n")
 
end
res = res .. "|- style=\"background:#C0C0C0;\"\n"
res = res .. "|align=center| [[" .. getMonthNameInGeorgian((month - 2) % 12 + 1) .. "| << ]]\n"
res = res .. "|colspan=\"5\"|'''[[" .. monthName .. "]]'''\n"
res = res .. "|align=center| [[" .. getMonthNameInGeorgian(month % 12 + 1) .. "| << ]]\n"
res = res .. "|- style=\"background:#DCDCDC;\"\n"
res = res .. "|width=\"14%\"|ორშ\n"
res = res .. "|width=\"14%\"|სამ\n"
res = res .. "|width=\"14%\"|ოთხ\n"
res = res .. "|width=\"14%\"|ხუთ\n"
res = res .. "|width=\"14%\"|პარ\n"
res = res .. "|width=\"14%\"|შაბ\n"
res = res .. "|width=\"14%\"|კვი\n"
res = res .. "|-\n"
 
for i = 1, firstWeekday - 1 do
res = res .. "|\n"
end
 
for i = 1, daysInMonth do
res = res .. "|[[" .. i .. " " .. monthName .. "|" .. i .. "]]\n"
res = res .. ((i + firstWeekday - 1) % 7 == 0 and "|-\n" or "")
end
 
for i = 1, daysInMonth do
res = res .. addRow("|[[" .. i .. " " .. monthName .. "|" .. i .. "]]\n")
res = res .. addRow(((i + firstWeekday - 1) % 7 == 0 and "|-\n" or ""))
end
 
res = res .. addRow("|- style=\"background:#DCDCDC" .. color .. ";\"\n")
res = res .. addRow("|colspan=\"7\"|'''[[" .. year .. "]]'''\n")
addRow("|}")
res = res .. "|}"
 
return restable.concat(root)
end