|
|
| שורה 101: |
שורה 101: |
| inputstr:gsub(pattern, function(c) fields[#fields + 1] = c end) | | inputstr:gsub(pattern, function(c) fields[#fields + 1] = c end) |
| return fields | | return fields |
| end
| |
|
| |
| function addMissingImage(infoObj, birthDate, deathDate, gender)
| |
| if infoObj.args.image ~= nil and #infoObj.args.image > 0 then return end -- there is already image
| |
|
| |
| local dateModule = require('Module:דאטום')
| |
|
| |
| -- Assuming you have defined deathDate and birthDate earlier
| |
| local latestDate = deathDate or birthDate
| |
| if latestDate == nil then return end
| |
|
| |
| -- Split the comma-separated lists and extract dates
| |
| local dateList = splitString(latestDate:gsub(" או ", ","), ",")
| |
| if #dateList == 0 then return end
| |
|
| |
| local iso8601DateList = {}
| |
| local latestIsoDate = 0
| |
| local indexOfLatestIsoDate = 0
| |
|
| |
| -- Convert the dates to ISO 8601 format
| |
| for i, isoDate in ipairs(dateList) do
| |
| local successOfIso8601DateList
| |
| successOfIso8601DateList, iso8601DateList[i] = pcall(dateModule.parseStrDate, isoDate, 'TS')
| |
| if (i == 1) then
| |
| latestIsoDate = iso8601DateList[1]
| |
| indexOfLatestIsoDate = 1
| |
| else
| |
| if (latestIsoDate > iso8601DateList[i]) then
| |
| latestIsoDate = iso8601DateList[i]
| |
| indexOfLatestIsoDate = i
| |
| end
| |
| end
| |
| end
| |
|
| |
| -- If needed, you can convert the latest ISO 8601 date back to a readable format
| |
| latestDate = dateList[indexOfLatestIsoDate]
| |
|
| |
| local success, res = pcall(dateModule.parseDateRange, latestDate, 'raw')
| |
| if success==false then return end -- there is no known VALID date
| |
| local yearsEstimated = res/(60*60*24*365)
| |
| if yearsEstimated>150 then return end
| |
|
| |
| local frame = mw.getCurrentFrame()
| |
| infoObj.args.image = frame:expandTemplate{ title = 'אין תמונה', args = { gender, ['יישור'] = 'מרכז' } }
| |
| end | | end |
|
| |
|