יחידה:גיל לערכי אישים: הבדלים בין גרסאות בדף

קריאה לתבנית "גיל לערכי אישים/בעיה" גם במקרה שפורמט התאריך חוקי אך אינו מדויק (כמו "המאה ה-11")
ביטול גרסה 27459777 של Dovno (שיחה) עדיין לא מבצע את הצפוי
שורה 9: שורה 9:
local isValidDate, res = pcall(dateParser.newFromWikitext, Date)
local isValidDate, res = pcall(dateParser.newFromWikitext, Date)
local errors = ''
local errors = ''
if isValidDate and dateParser.age(res).year<0 then
if not isValidDate then
-- date is in the future
-- invalid date
errors = frame:expandTemplate{ title = 'גיל לערכי אישים/בעיה', args = {
['מקורב']=ApproxDate,
['נוסף']=Date,
['מחרוזת']=Date
} }
-- validate
elseif dateParser.age(res).year<0 then  
isValidDate = false
isValidDate = false
local title = mw.title.getCurrentTitle()
local title = mw.title.getCurrentTitle()
if title.namespace==0 then
if title.namespace==0 then
errors = Errors['future-date']
errors = Errors['future-date']-- date is in the future
else
else
errors = '<!--' .. Errors['future-date'] .. '-->'
errors = '<!--' .. Errors['future-date'] .. '-->'
end
end
elseif not isValidDate or res.precision < dateParser.PRECISION.YEAR then
-- date is either invalid or is imprecise
errors = frame:expandTemplate{ title = 'גיל לערכי אישים/בעיה', args = {
['מקורב']=ApproxDate,
['נוסף']=Date,
['מחרוזת']=Date
} }
end
end
return isValidDate, res, errors
return isValidDate, res, errors