יחידה:גיל לערכי אישים: הבדלים בין גרסאות בדף
מ טיפול בפעוטות |
מ ריבוי אפשרויות |
||
| שורה 31: | שורה 31: | ||
function consistentWithWikidata(localDate, wikidataClaim) | function consistentWithWikidata(localDate, wikidataClaim) | ||
local possibleDate, possibleDateValue, isConsistent | |||
if not wikidataClaim then | if not wikidataClaim then | ||
return true | return true | ||
end | end | ||
local iswikidataValid, wikidataDate = pcall(dateParser.newFromWikidataValue, | isConsistent = true | ||
for i,possibleDate in ipairs(wikidataClaim) do | |||
if possibleDate.mainsnak and possibleDate.mainsnak.datavalue and possibleDate.mainsnak.datavalue.value then | |||
possibleDateValue = possibleDate.mainsnak.datavalue.value | |||
local iswikidataValid, wikidataDate = pcall(dateParser.newFromWikidataValue, possibleDateValue) | |||
if iswikidataValid and localDate.calendar == wikidataDate.calendar then | |||
if (localDate.year ~= wikidataDate.year and possibleDateValue.precision>=dateParser.PRECISION.YEAR) or | |||
(localDate.month ~= wikidataDate.month and possibleDateValue.precision>=dateParser.PRECISION.MONTH) or | |||
return | (localDate.day ~= wikidataDate.day and possibleDateValue.precision>=dateParser.PRECISION.DAY) then | ||
isConsistent = false | |||
else | |||
isConsistent = true | |||
break | |||
end | |||
end | |||
end | |||
end | |||
return isConsistent | |||
end | end | ||
| שורה 84: | שורה 94: | ||
end | end | ||
if wikidataBirth and wikidataBirth[1] and wikidataBirth[1].mainsnak then | if wikidataBirth and wikidataBirth[1] and wikidataBirth[1].mainsnak then | ||
if not consistentWithWikidata(BirthDate, wikidataBirth) then | if not consistentWithWikidata(BirthDate, wikidataBirth) then | ||
table.insert(warnings, '[[קטגוריה:דפים עם שנות חיים שלא תואמים את ויקינתונים]]') | table.insert(warnings, '[[קטגוריה:דפים עם שנות חיים שלא תואמים את ויקינתונים]]') | ||