Module:Dagar
Útlit
Hægt er að búa til leiðbeiningar fyrir þessa skriftu á Module:Dagar/doc
local mEaster = require("Module:Easter")
-- Format: yyyy-mm-dd
local year = os.date("*t").year
local year_f = year .. "-"
local today = year_f .. os.date("*t").month .. "-" .. os.date("*t").day
local p = {}
local function getEaster(holiday)
return mEaster.Calculate({
args = { year, dagur = holiday, form = "Y-m-d"}
})
end
local data = {
-- Fastir dagar (mm-dd)
{ d = year_f .. "01-01", n = "[[Nýár]]sdagur" },
{ d = year_f .. "01-06", n = "[[Þrettándinn]]" },
{ d = year_f .. "02-14", n = "[[Valentínusardagurinn]]" },
{ d = year_f .. "05-01", n = "[[Verkalýðsdagurinn]]" },
{ d = year_f .. "06-17", n = "[[Íslenski þjóðhátíðardagurinn|Þjóðhátíðardagur Íslendinga]]" },
{ d = year_f .. "06-26", n = "Fæðingardagur [[Guðni Th. Jóhannesson|forseta]]" }, -- (?)
{ d = year_f .. "10-31", n = "[[Hrekkjavaka]]" },
{ d = year_f .. "11-16", n = "[[Dagur íslenskrar tungu]]" },
{ d = year_f .. "12-01", n = "[[Fullveldisdagurinn]]" },
{ d = year_f .. "12-24", n = "[[Aðfangadagur]]" },
{ d = year_f .. "12-25", n = "[[Jóladagur]]" },
{ d = year_f .. "12-31", n = "[[Gamlárskvöld|Gamlársdagur]]" },
-- Dagar sem nota Module:Easter
{ d = getEaster("Langafasta"), n = "[[Langafasta]]" },
{ d = getEaster("Bolludagur"), n = "[[Bolludagur]]" },
{ d = getEaster("Sprengidagur"), n = "[[Sprengidagur]]" },
{ d = getEaster("Öskudagur"), n = "[[Öskudagur]]" },
{ d = getEaster("Dymbilvika"), n = "[[Dymbilvika]]" },
{ d = getEaster("Pálmasunnudagur"), n = "[[Pálmasunnudagur]]" },
{ d = getEaster("Skírdagur"), n = "[[Skírdagur]]" },
{ d = getEaster("Föstudagurinn langi"), n = "[[Föstudagurinn langi]]" },
{ d = getEaster("Páskar"), n = "[[Páskadagur]]" },
{ d = getEaster("Uppstigningardagur"), n = "[[Uppstigningardagur]]" },
{ d = getEaster("Hvítasunnudagur"), n = "[[Hvítasunnudagur]]" },
-- Annar í Hvítasunnu: "Annar í [[Hvítasunnudagur#Frídagur á Íslandi|Hvítasunnu]]""
{ d = getEaster("Langafasta"), n = "[[Langafasta]]" },
-- Aðrir dagar (yyyy-mm-dd)
---- Norræna tímatalið
{ n = "[[Bóndadagur]] (upphaf [[Þorri|þorra]])", d = {
"2023-01-20", "2024-01-19", "2025-01-24", "2026-01-23",
"2027-01-22", "2028-01-21", "2029-01-19", "2030-01-25"
}},
{ n = "[[Konudagur]] (upphaf [[Góa|góu]])", d = {
"2023-02-19", "2024-02-18", "2025-02-23", "2026-02-22",
"2027-02-21", "2028-02-20", "2029-02-18", "2030-02-24"
}},
{ n = "[[Sumardagurinn fyrsti]]", d = {
"2023-04-20", "2024-04-25", "2025-04-24", "2026-04-23",
"2027-04-22", "2028-04-20", "2029-04-19", "2030-04-25"
}},
{ n = "[[Fyrsti vetrardagur]]", d = {
"2023-10-28", "2024-10-26", "2025-10-25", "2026-10-24",
"2027-10-23", "2028-10-21", "2029-10-27", "2030-10-26"
}},
---- Íslenskir dagar
{ n = "[[Sjómannadagurinn]]", d = {
"2023-06-04", "2024-06-02", "2025-06-01", "2026-06-07",
"2027-06-06", "2028-06-11", "2029-06-03", "2030-06-02"
}},
{ n = "[[Verslunarmannahelgin]]", d = {
"2023-08-04", "2023-08-05", "2023-08-06", -- 2023
"2024-08-02", "2024-08-03", "2024-08-04", -- 2024
"2025-08-01", "2025-08-02", "2025-08-03", -- 2025
"2026-07-31", "2026-08-01", "2026-08-02", -- 2026
"2027-07-30", "2027-07-31", "2027-08-01", -- 2027
"2028-08-04", "2028-08-05", "2028-08-06", -- 2028
"2029-08-03", "2029-08-04", "2029-08-05", -- 2029
"2030-08-02", "2030-08-03", "2030-08-04" -- 2030
}},
{ n = "[[Frídagur verslunarmanna]]", d = {
"2023-08-07", "2024-08-05", "2025-08-04", "2026-08-03",
"2027-08-02", "2028-08-07", "2029-08-06", "2030-08-05"
}},
{ n = "[[Hinsegin dagar|Gleðigangan]]", d = {
"2023-08-12", "2024-08-10", "2025-08-09", "2026-08-08",
"2027-08-07", "2028-08-12", "2029-08-11", "2030-08-10"
}},
{ n = "[[Menningarnótt]]", d = {
"2023-08-19", "2024-08-24", "2025-08-23", "2026-08-22",
"2027-08-21", "2028-08-19", "2029-08-18", "2030-08-24"
}},
-- Alþjóðlegir dagar
{ n = "[[Mæðradagurinn]]", d = {
"2023-05-14", "2024-05-12", "2025-05-11", "2026-05-10",
"2027-05-09", "2028-05-14", "2029-05-13", "2030-05-12"
}},
{ n = "[[Feðradagurinn]]", d = {
"2023-11-12", "2024-11-10", "2025-11-09", "2026-11-08",
"2027-11-14", "2028-11-12", "2029-11-11", "2030-11-10"
}}
}
local result = ""
local function addToResult(day, name)
if day == today then
if #result > 0 then
result = result .. " <b>·</b> " .. name -- Breyta separator?
else
result = name
end
end
end
local function findYear(date_inp)
local t = {}
for str in string.gmatch(date_inp, "([^-]+)") do
table.insert(t, str)
end
return t[1]
end
function p.main(frame)
local pframe = frame:getParent()
local args = pframe.args
local conf = frame.args
-- Breyta degi ef input (yyyy-mm-dd)
-- fixme: breyta year í yyyy og year_f í yyyy- (af yyyy-mm-dd) úr input til að það virki
-- fixme: uppfærist ekki
if conf[1] then
year = findYear(conf[1])
year_f = findYear(conf[1]) .. "-"
today = conf[1]
end
for _, obj in pairs(data) do
local obd = obj["d"] -- Date
local obn = obj["n"] -- Title
if type(obd) == "table" then
for _, day in pairs(obd) do
addToResult(day, obn)
end
else
addToResult(obd, obn)
end
end
return result
end
return p