وحدة:وفيات
من أرابيكا، الموسوعة العربية الحرة
المزيد من اللغات
المزيد من الإجراءات
local p = {}
local months_ar = {
["يناير"] = 1, ["فبراير"] = 2, ["مارس"] = 3, ["أبريل"] = 4,
["مايو"] = 5, ["يونيو"] = 6, ["يوليو"] = 7, ["أغسطس"] = 8,
["سبتمبر"] = 9, ["أكتوبر"] = 10, ["نوفمبر"] = 11, ["ديسمبر"] = 12
}
local months_ar_r = {
[1] = "يناير", [2] = "فبراير", [3] = "مارس", [4] = "أبريل",
[5] = "مايو", [6] = "يونيو", [7] = "يوليو", [8] = "أغسطس",
[9] = "سبتمبر", [10] = "أكتوبر", [11] = "نوفمبر", [12] = "ديسمبر"
}
local function getDaysInMonth(month, year)
if not month or not year then return 28 end
local m = months_ar[month]
if not m then return 28 end
if m == 12 then
year = year + 1
m = 1
else
m = m + 1
end
local t = os.time{year = year, month = m, day = 1}
return tonumber(os.date("*t", t - 86400).day)
end
local function getPrevMonth(m, y)
if m == 1 then return 12, y - 1 else return m - 1, y end
end
local function getNextMonth(m, y)
if m == 12 then return 1, y + 1 else return m + 1, y end
end
function p.daysList(frame)
local title = mw.title.getCurrentTitle().text or ""
local args = frame:getParent().args
local refs = args["refs"] or args["مصدر"]
local m_ar, y = mw.ustring.match(title, "وفيات%s+(%S+)%s+(%d%d%d%d)")
y = tonumber(y)
if m_ar and months_ar[m_ar] then
-- حالة: "وفيات مارس 2025"
local m_num = months_ar[m_ar]
local days = getDaysInMonth(m_ar, y)
local output = {}
table.insert(output, '<div style="clear: both"></div>')
for i = 1, 28 do
table.insert(output, string.format("* [[#%d|%d]]", i, i))
end
if days >= 29 then table.insert(output, "* [[#29|29]]") end
if days >= 30 then table.insert(output, "* [[#30|30]]") end
if days == 31 then table.insert(output, "* [[#31|31]]") end
if refs == "yes" then
table.insert(output, "* [[#المراجع|المراجع]]")
end
local prev_m, prev_y = getPrevMonth(m_num, y)
local next_m, next_y = getNextMonth(m_num, y)
table.insert(output, '<div style="display: flex; text-align: center">')
table.insert(output, string.format(
'<div style="width: 30%%">[[وفيات %s %d|→ %s]]</div>',
months_ar_r[prev_m], prev_y, months_ar_r[prev_m]
))
table.insert(output, string.format('<div style="flex-grow: 1">%s</div>', m_ar))
table.insert(output, string.format(
'<div style="width: 30%%">[[وفيات %s %d|%s ←]]</div>',
months_ar_r[next_m], next_y, months_ar_r[next_m]
))
table.insert(output, '</div>')
table.insert(output, '<div style="clear: both"></div>')
return table.concat(output, "\n")
else
local y_only = mw.ustring.match(title, "وفيات%s+(%d%d%d%d)")
y_only = tonumber(y_only)
if y_only then
local out = {}
table.insert(out, '<div style="clear: both"></div>')
for i = 1, 12 do
local name = months_ar_r[i]
table.insert(out, string.format("* [[#وفيات %s|%s]]", name, name))
end
if refs == "yes" then
table.insert(out, "* [[#المراجع|المراجع]]")
end
table.insert(out, '<div style="clear: both"></div>')
return table.concat(out, "\n")
else
return "تعذر تحديد نوع الصفحة من العنوان: " .. title
end
end
end
return p