מייבאים כמותיים, בדוקי עריכות אוטומטית, אינטערפעיס אדמיניסטראַטאָרן, מנטרים, מייבאים, מעדכנים, אספקלריה רעדאקטארן
3,951
רעדאגירונגען
אין תקציר עריכה |
אין תקציר עריכה |
||
| (9 צווישנדיגע ווערסיעס פונעם זעלבן באַניצער נישט געוויזן) | |||
| שורה 3: | שורה 3: | ||
-- פונקציית עזר – החזרת אות בעברית או מספר | -- פונקציית עזר – החזרת אות בעברית או מספר | ||
local function gim(n) | local function gim(n) | ||
if n > 10 then | |||
error("gim: input out of range (must be 1–10), got " .. tostring(n)) | |||
end | |||
local a = "אבגדהוזחכש" | local a = "אבגדהוזחכש" | ||
return mw.ustring.sub(a, n, n) | return mw.ustring.sub(a, n, n) | ||
end | end | ||
-- | -- Private: Compute Rosh Hashanah dates (JDN) for year and year+1 | ||
function | local function rosh_pair(y) | ||
local b = 38004 + 765433 * math.floor((235 * y - 234) / 19) | |||
local d = math.floor(b / 25920) | |||
local e = b % 25920 | |||
local f = 1 + (d % 7) | |||
local g = math.floor(((7 * y + 13) % 19) / 12) | |||
local h = math.floor(((7 * y + 6) % 19) / 12) | |||
if (e >= 16404 and f == 3 and g == 0) or (e >= 23269 and f == 2 and h == 1) then | |||
d = d + 1 | |||
e = e - 25920 | |||
end | |||
local j1 = d + ((d + 5) % 7) % 2 + 347997 | |||
b = e + 9516 + 39673 * g | |||
d = d + math.floor(b / 25920) + 354 + 28 * g | |||
e = b % 25920 | |||
f = 1 + (d % 7) | |||
h = math.floor(((7 * y + 1) % 19) / 12) | |||
if (e >= 16404 and f == 3 and h == 0) or (e >= 23269 and f == 2 and g == 1) then | |||
d = d + 1 | |||
end | |||
local j2 = d + ((d + 5) % 7) % 2 + 347997 | |||
return {j1, j2} | |||
end | |||
local | -- Convert JDN to Gregorian/Julian MM/DD | ||
local function jd_to_date(j, julian) | |||
local f = j + 1401 | |||
if not julian then | |||
f = f + math.floor((math.floor((4 * j + 274277) / 146097) * 3) / 4) - 38 | |||
end | |||
local e = 4 * f + 3 | |||
local g = math.floor((e % 1461) / 4) | |||
local h = 5 * g + 2 | |||
local m = ((math.floor(h / 153) + 2) % 12) + 1 | |||
local d = math.floor((h % 153) / 5) + 1 | |||
return m .. "/" .. d | |||
end | |||
-- מקבלת שנה עברית ומחזירה סימן (למשל "הכז") | |||
p["סימן"] = function(frame) | |||
local y = tonumber(frame.args[1] or frame.args["year"]) | |||
if not y or y <= 0 then return "שנה לא תקפה" end | |||
local r = rosh_pair(y) | |||
local w1 = (r[1] + 1) % 7 + 1 | |||
local diff = (r[2] - r[1]) % 10 + 5 | |||
local w2 = (r[2] - 1) % 7 + 1 | |||
return gim(w1) .. gim(diff) .. gim(w2) | |||
end | |||
-- אפשניט אין ציווילע קאלענדערס | |||
p["אפשניט"] = function(frame) | |||
local y = tonumber(frame.args[1] or frame.args["year"]) | |||
local c = frame.args[2] or frame.args["cal"] | |||
if not y then return "Invalid year" end | |||
if not c then c = "ה" end | |||
local r = rosh_pair(y) | |||
if c == "ג" then | |||
return jd_to_date(r[1], false) .. "–" .. jd_to_date(r[2]-1, false) | |||
elseif c == "י" then | |||
return jd_to_date(r[1], true) .. "–" .. jd_to_date(r[2]-1, true) | |||
elseif c == "ה" then | |||
if y <= 5342 then | |||
return jd_to_date(r[1], true) .. "–" .. jd_to_date(r[2]-1, true) | |||
elseif y >= 5344 then | |||
return jd_to_date(r[1], false) .. "–" .. jd_to_date(r[2]-1, false) | |||
elseif y == 5343 then | |||
return jd_to_date(r[1], true) .. "–" .. jd_to_date(r[2]-1, false) | |||
end | |||
end | |||
return "Invalid" | |||
end | end | ||
return p | return p | ||
רעדאגירונגען