יחידה:גיל לערכי אישים: הבדלים בין גרסאות בדף
קריאה לתבנית "גיל לערכי אישים/בעיה" גם במקרה שפורמט התאריך חוקי אך אינו מדויק (כמו "המאה ה-11") |
|||
| שורה 9: | שורה 9: | ||
local isValidDate, res = pcall(dateParser.newFromWikitext, Date) | local isValidDate, res = pcall(dateParser.newFromWikitext, Date) | ||
local errors = '' | local errors = '' | ||
if isValidDate | if not isValidDate then | ||
-- 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 | ||
end | end | ||
return isValidDate, res, errors | return isValidDate, res, errors | ||