יחידה:גיל לערכי אישים: הבדלים בין גרסאות בדף
קריאה לתבנית "גיל לערכי אישים/בעיה" גם במקרה שפורמט התאריך חוקי אך אינו מדויק (כמו "המאה ה-11") |
מ 5 גרסאות של הדף wikipedia:he:יחידה:גיל_לערכי_אישים יובאו |
||
| (15 גרסאות ביניים של 6 משתמשים אינן מוצגות) | |||
| שורה 20: | שורה 20: | ||
elseif not isValidDate or res.precision < dateParser.PRECISION.YEAR then | elseif not isValidDate or res.precision < dateParser.PRECISION.YEAR then | ||
-- date is either invalid or is imprecise | -- date is either invalid or is imprecise | ||
isValidDate = false -- mark as invalid anyway, even if "only" imprecise | |||
errors = frame:expandTemplate{ title = 'גיל לערכי אישים/בעיה', args = { | errors = frame:expandTemplate{ title = 'גיל לערכי אישים/בעיה', args = { | ||
['מקורב']=ApproxDate, | ['מקורב']=ApproxDate, | ||
| שורה 71: | שורה 72: | ||
end | end | ||
function ageCalc(BirthDateStr, DeathDateStr, DisplayForAlive, DisplayForDead, Brackets, ApproxDate) | function ageCalc(BirthDateStr, DeathDateStr, DisplayForAlive, DisplayForDead, Brackets, ApproxDate, gender) | ||
local frame = mw.getCurrentFrame() | local frame = mw.getCurrentFrame() | ||
local warnings = {} | local warnings = {} | ||
| שורה 122: | שורה 123: | ||
else | else | ||
if gender == nil and entityId~=nil then | |||
local PropertyLink = require('Module:PropertyLink') | |||
gender = PropertyLink.getItem( 'P21', entityId ) | |||
if (gender == "Q6581097") then -- male | |||
gender = 'זכר' | |||
elseif (gender == "Q2449503") then -- transgender male | |||
gender = 'זכר' | |||
elseif (gender == "Q15145778") then -- cisgender male | |||
gender = 'זכר' | |||
elseif (gender == "Q6581072") then -- female | |||
gender = 'נקבה' | |||
elseif (gender == "Q1052281") then -- transgender female | |||
gender = 'נקבה' | |||
elseif (gender == "Q15145779") then -- cisgender female | |||
gender = 'נקבה' | |||
end | |||
end | |||
prefix = 'גיל: ' | |||
if gender == 'נקבה' then | |||
prefix = 'בת ' | |||
elseif gender == 'זכר' then | |||
prefix = 'בן ' | |||
end | |||
end | end | ||
-- skip age calculation if we dont have enough precision | -- skip age calculation if we dont have enough precision | ||
if DeathDate and DeathDate.precision and DeathDate.precision < dateParser.PRECISION.YEAR then return nil end | if DeathDate and DeathDate.precision and DeathDate.precision < dateParser.PRECISION.YEAR then return nil end | ||
| שורה 137: | שורה 156: | ||
if success then | if success then | ||
AgeYears = Age.year | AgeYears = Age.year | ||
if Age.year | if Age.year <= 0 then | ||
if Age.month == 1 then | if Age.month == 1 then | ||
result = prefix..'חודש' | result = prefix..'חודש' | ||
| שורה 160: | שורה 179: | ||
result = prefix..'שנתיים' | result = prefix..'שנתיים' | ||
end | end | ||
if Age.month == 1 then | if Age.month == 0 then | ||
if Age.day > 0 then | |||
if Age.day == 1 then | |||
result = result..' ויום' | |||
elseif Age.day == 2 then | |||
result = result..' ויומיים' | |||
else | |||
result = result..' ו־'..tostring(Age.day)..' ימים' | |||
end | |||
end | |||
elseif Age.month == 1 then | |||
result = result..' וחודש' | result = result..' וחודש' | ||
elseif Age.month == 2 then | elseif Age.month == 2 then | ||
| שורה 176: | שורה 205: | ||
end | end | ||
-- ignore warning in specific template | |||
local noAgeWarning = false | |||
if mw.getCurrentFrame():getParent():getTitle() == 'תבנית:אישיות תנ"כית' or mw.getCurrentFrame():getParent():getTitle() == 'תבנית:בעל חיים מפורסם' then | |||
noAgeWarning = true | |||
end | |||
local title = mw.title.getCurrentTitle() | local title = mw.title.getCurrentTitle() | ||
-- ignore warning in other namespace except the main NS | -- ignore warning in other namespace except the main NS | ||
if title.namespace==0 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]]') | ||