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

1,929 בייטן צוגעלייגט ,  פֿאַר 2 יאָר
באהאנדלען אויך {{לינק צו אידיש יאר}}
ק (גיל = עלטער אדער יארגאנג? (diffedit))
(באהאנדלען אויך {{לינק צו אידיש יאר}})
 
(17 מיטלסטע ווערסיעס פון 2 באַניצער נישט געוויזן.)
שורה 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 = {
['future-date'] = '[[קאטעגאריע:אומריכטיגע לעבן דאטומען]]'
['future-date'] = '[[קאטעגאריע:אומריכטיגע לעבן דאטומען]]'
}
}
function count(str, substring)
    local count = 0
    local _, occurrences = string.gsub(str, substring, function()
        count = count + 1
    end)
    return count
end


function ToDate(frame, Date, ApproxDate)
function ToDate(frame, Date, ApproxDate)
שורה 59: שורה 68:
local args = Arguments.getArgs(frame, { ['trim'] = true, ['removeBlanks'] = true })
local args = Arguments.getArgs(frame, { ['trim'] = true, ['removeBlanks'] = true })
--local age_string = args['מציין']
--local age_string = args['מציין']
local BirthDateStr = args['געבורט דאטום']
local BirthDateStr = args['געבורט דאטום'] or args['תאריך לידה עברי']
local DeathDateStr = args['פטירה דאטום']
local l = frame:preprocess(args['תאריך לידה עברי']) -- preprocess, to handle {{לינק צו אידיש יאר}}
    if args['געבורט דאטום'] == nil and (#mw.text.split(l, '%s' ) == 1 or count(l, "%[%[") == 1) then --most probably just year or yearlink
    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 p = frame:preprocess(args['תאריך פטירה עברי'])
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
local DisplayForAlive = args['הצג אם בחיים']
local DisplayForAlive = args['הצג אם בחיים']
local DisplayForDead = args['הצג אם נפטר']
local DisplayForDead = args['הצג אם נפטר']
שורה 206: שורה 242:
-- ignore warning in specific template
-- ignore warning in specific template
local noAgeWarning = false
local noAgeWarning = false
if mw.getCurrentFrame():getParent():getTitle() == 'מוסטער:אישיות תנ"כית' then
if mw.getCurrentFrame():getParent():getTitle() == 'מוסטער:תנ"ך פערזענליכקייט' or mw.getCurrentFrame():getParent():getTitle() == 'מוסטער:בעל חיים מפורסם' then
noAgeWarning = true
noAgeWarning = true
end
end
שורה 213: שורה 249:
if title.namespace==0 and not noAgeWarning then
if title.namespace==0 and not noAgeWarning then
if AgeYears > 139 then  
if AgeYears > 139 then  
table.insert(warnings, Errors['future-date'])
local instanceOf = entityId and mw.wikibase.getBestStatements( entityId, 'P31' )
local isHuman = instanceOf and instanceOf[1].mainsnak and instanceOf[1].mainsnak.datavalue.value.id=='Q5'
if isHuman then
table.insert(warnings, Errors['future-date'])
end
elseif AgeYears>109 then  
elseif AgeYears>109 then  
table.insert(warnings, '[[קאטעגאריע:מענטשן וואס זענען אנגעקומען צו די 110]]')
table.insert(warnings, '[[קאטעגאריע:מענטשן וואס זענען אנגעקומען צו די 110]]')