אונטערשייד צווישן ווערסיעס פון "יחידה:קביעות"

339 בייטן אראפגענומען ,  פֿאַר 4 חדשים
קיין רעדאגירונג באמערקונג
אין תקציר עריכה
אין תקציר עריכה
שורה 12: שורה 12:
-- Private: Compute Rosh Hashanah dates (JDN) for year and year+1
-- Private: Compute Rosh Hashanah dates (JDN) for year and year+1
local function rosh_pair(y)
local function rosh_pair(y)
    local parts = 38004 + 765433 * math.floor((235 * y - 234) / 19)
local b = 38004 + 765433 * math.floor((235 * y - 234) / 19)
    local days = math.floor(parts / 25920)
local d = math.floor(b / 25920)
    local part_rem = parts % 25920
local e = b % 25920
    local weekday = 1 + (days % 7)
local f = 1 + (d % 7)
local g = math.floor(((7 * y + 13) % 19) / 12)
local h = math.floor(((7 * y + 6) % 19) / 12)


    local ibur1 = math.floor(((7 * y + 13) % 19) / 12)
if (e >= 16404 and f == 3 and g == 0) or (e >= 23269 and f == 2 and h == 1) then
    local ibur2 = math.floor(((7 * y + 6) % 19) / 12)
d = d + 1
e = e - 25920
end


    if (part_rem >= 16404 and weekday == 3 and ibur1 == 0)
local j1 = d + ((d + 5) % 7) % 2 + 347997
        or (part_rem >= 23269 and weekday == 2 and ibur2 == 1) then
        days = days + 1
        part_rem = part_rem - 25920
    end


    local jdn1 = days + ((days + 5) % 7) % 2
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)


    parts = part_rem + 9516 + (13753 * ibur1)
if (e >= 16404 and f == 3 and h == 0) or (e >= 23269 and f == 2 and g == 1) then
    days = days + math.floor(parts / 25920) + 354 + 29 * ibur1
d = d + 1
    part_rem = parts % 25920
end
    weekday = 1 + (days % 7)
    ibur2 = math.floor(((7 * y + 1) % 19) / 12)
 
    if (part_rem >= 16404 and weekday == 3 and ibur2 == 0)
        or (part_rem >= 23269 and weekday == 2 and ibur1 == 1) then
        days = days + 1
    end


    local jdn2 = days + ((days + 5) % 7) % 2
local j2 = d + ((d + 5) % 7) % 2 + 347997
    return { jdn1, jdn2 }
return {j1, j2}
end
end


שורה 60: שורה 58:
p["סימן"] = function(frame)
p["סימן"] = function(frame)
     local y = tonumber(frame.args[1] or frame.args["year"])
     local y = tonumber(frame.args[1] or frame.args["year"])
     if not y then return "Invalid year" end
     if not y or y <= 0 then return "שנה לא תקפה" end
     local roshs = rosh_pair(y)
     local r = rosh_pair(y)
     return gim((roshs[1] % 7) + 1) ..
     local w1 = (r[1] + 1) % 7 + 1
          gim(((roshs[2] - roshs[1]) % 10) + 5) ..
local diff = (r[2] - r[1]) % 10 + 5
          gim(((roshs[2] - 2) % 7) + 1)
local w2 = (r[2] - 1) % 7 + 1
return gim(w1) .. gim(diff) .. gim(w2)
end
end
-- אפשניט אין ציווילע קאלענדערס
-- אפשניט אין ציווילע קאלענדערס
שורה 72: שורה 71:
     if not y then return "Invalid year" end
     if not y then return "Invalid year" end
     if not c then return "Missing calendar type" end
     if not c then return "Missing calendar type" end
     local roshs = rosh_pair(y)
     local r = rosh_pair(y)
    if c == "ג" then
if c == "ג" then
        return jd_to_date(roshs[1]) .. "-" .. jd_to_date(roshs[2])
return jd_to_date(r[1], false) .. "-" .. jd_to_date(r[2], false)
    elseif c == "י" then
elseif c == "י" then
        return jd_to_date(roshs[1], true) .. "-" .. jd_to_date(roshs[2], true)
return jd_to_date(r[1], true) .. "-" .. jd_to_date(r[2], true)
    elseif c == "ה" then
elseif c == "ה" then
        if y <= 5342 then
if y <= 5342 then
            return jd_to_date(roshs[1], true) .. "-" .. jd_to_date(roshs[2], true)
return jd_to_date(r[1], true) .. "-" .. jd_to_date(r[2], true)
        elseif y >= 5344 then
elseif y >= 5344 then
            return jd_to_date(roshs[1]) .. "-" .. jd_to_date(roshs[2])
return jd_to_date(r[1], false) .. "-" .. jd_to_date(r[2], false)
        elseif y == 5343 then
elseif y == 5343 then
            return jd_to_date(roshs[1], true) .. "-" .. jd_to_date(roshs[2])
return jd_to_date(r[1], true) .. "-" .. jd_to_date(r[2], false)
        end
end
    end
end
     return "Invalid"
     return "Invalid"
end
end
return p
return p