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

ביטול גרסה 27459777 של Dovno (שיחה) עדיין לא מבצע את הצפוי
שחזור לגרסה 27459777 מ־09:45, 11 במרץ 2020 מאת Dovno, עם תיקון - גם אם תאריך הוא תקין מבחינת יחידה:תאריך, לצורך חישוב הגיל הוא אינו תקין אם הוא מקורב ("המאה ה-11")
שורה 9: שורה 9:
local isValidDate, res = pcall(dateParser.newFromWikitext, Date)
local isValidDate, res = pcall(dateParser.newFromWikitext, Date)
local errors = ''
local errors = ''
if not isValidDate then
if isValidDate and dateParser.age(res).year<0 then
-- invalid date
-- date is in the future
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']-- date is in the future
errors = Errors['future-date']
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
isValidDate = false -- mark as invalid anyway, even if "only" imprecise
errors = frame:expandTemplate{ title = 'גיל לערכי אישים/בעיה', args = {
['מקורב']=ApproxDate,
['נוסף']=Date,
['מחרוזת']=Date
} }
end
end
return isValidDate, res, errors
return isValidDate, res, errors