მოდული:კალენდარი: განსხვავება გადახედვებს შორის
შიგთავსი ამოიშალა შიგთავსი დაემატა
ახალი გვერდი: require('Module:No globals') local p = {} local function getMonthNameInGeorgian(month) return ({"იანვარი","თებერვალი","მ... |
(განსხვავება არ არის)
|
22:17, 21 ივლისი 2018-ის ვერსია
შეგიძლიათ შექმნათ დოკუმენტაცია ამ მოდულისათვის: მოდული:კალენდარი/ინფო
require('Module:No globals')
local p = {}
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.year)
local firstWeekday = tonumber(os.date("%w",os.time{year=year, month=month, day=1}))
local monthName = getMonthNameInGeorgian(month)
local daysInMonth = getDaysInMonth(month, year)
local res = "{| class=\"infobox\" style=\"float:right; margin-left: 1em; text-align:center;\" cellpadding=2 cellspacing=0\n"
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
res = res .. "|- style=\"background:#DCDCDC;\"\n"
res = res .. "|colspan=\"7\"|'''[[" .. year .. "]]'''\n"
res = res .. "|}"
return res
end
return p