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

509 בייטן צוגעלייגט ,  פֿאַר 2 יאָר
באהאנדלען אויך {{לינק צו אידיש יאר}}
(שנעלע פראבע צו באהאנדלען לפי קביעות הלוח יארן)
צייכן: צוריקגעשטעלט
(באהאנדלען אויך {{לינק צו אידיש יאר}})
 
(11 צווישנדיגע ווערסיעס פונעם זעלבן באַניצער נישט געוויזן)
שורה 1: שורה 1:
local dateParser = require( "Module:דאטום" )
local dateParser = require( "Module:דאטום" )
local Arguments = require( "Module:Arguments" )
local Arguments = require( "Module:Arguments" )
local gim = require( "Module:גימטריה" )


local Errors = {
local Errors = {
שורה 6: שורה 7:
}
}


function hebnum(s)
function count(str, substring)
numberstable = {
    local count = 0
["א"] = 1, ["ב"] = 2, ["ג"] = 3, ["ד"] = 4, ["ה"] = 5,
    local _, occurrences = string.gsub(str, substring, function()
["ו"] = 6, ["ז"] = 7, ["ח"] = 8, ["ט"] = 9, ["י"] = 10,
        count = count + 1
["כ"] = 20, ["ך"] = 20, ["ל"] = 30, ["מ"] = 40, ["ם"] = 40,
    end)
["נ"] = 50, ["ן"] = 50, ["ס"] = 60, ["ע"] = 70, ["פ"] = 80,
    return count
["ף"] = 80, ["צ"] = 90, ["ץ"] = 90, ["ק"] = 100, ["ר"] = 200,
["ש"] = 300, ["ת"] = 400, ["'"] = 0, ["\""] = 0,}
local ans = 0
local str = s
while len1(str) > 0 do
ans = ans + numberstable[sub1(str, 1, 1)]
str = sub1(str, 2, len1(str))
end
return ans
end
end


function ToDate(frame, Date, ApproxDate)
function ToDate(frame, Date, ApproxDate)
שורה 78: שורה 69:
--local age_string = args['מציין']
--local age_string = args['מציין']
local BirthDateStr = args['געבורט דאטום'] or args['תאריך לידה עברי']
local BirthDateStr = args['געבורט דאטום'] or args['תאריך לידה עברי']
     if args['געבורט דאטום'] == nil and #mw.text.split(args['תאריך לידה עברי'], '%s' ) == 1 then --most probably just year
local l = frame:preprocess(args['תאריך לידה עברי']) -- preprocess, to handle {{לינק צו אידיש יאר}}
BirthDateStr = hebnum(args['תאריך לידה עברי']) - 3760
     if args['געבורט דאטום'] == nil and (#mw.text.split(l, '%s' ) == 1 or count(l, "%[%[") == 1) then --most probably just year or yearlink
end
    if #mw.text.split(l, '%s' ) > 1 then
    l = l:match("%[%[.-|(.*)%]%]")
    end
    local birthParts = mw.text.split( l, "'", true )
local BirthDateNum = gim.gimatria(birthParts[1])*1000 + gim.gimatria(birthParts[2]) - 3760
if BirthDateNum < 1 then
BirthDateStr = tostring(math.abs(BirthDateNum)) .. " לפנה\"ס"
else
BirthDateStr = tostring(BirthDateNum)
end
    end
    --error(BirthDateStr)
local DeathDateStr = args['פטירה דאטום'] or args['תאריך פטירה עברי']
local DeathDateStr = args['פטירה דאטום'] or args['תאריך פטירה עברי']
if args['פטירה דאטום'] == nil and #mw.text.split( args['תאריך פטירה עברי'], '%s' ) == 1 then --most probably just year
local p = frame:preprocess(args['תאריך פטירה עברי'])
BirthDateStr = hebnum(args['תאריך פטירה עברי']) - 3760
if args['פטירה דאטום'] == nil and (#mw.text.split(p, '%s' ) == 1 or count(p, "%[%[") == 1) then --most probably just year or yearlink
    if #mw.text.split(p, '%s' ) > 1 then
    p = p:match("%[%[.-|(.*)%]%]")
    end
local deathParts = mw.text.split( p, "'", true )
local DeathDateNum = gim.gimatria(deathParts[1])*1000 + gim.gimatria(deathParts[2]) - 3760
if DeathDateNum < 1 then
DeathDateStr = tostring(math.abs(DeathDateNum)) .. " לפנה\"ס"
else
DeathDateStr = tostring(DeathDateNum)
end
end
end
local DisplayForAlive = args['הצג אם בחיים']
local DisplayForAlive = args['הצג אם בחיים']