Timeline
Jump to navigation
Jump to search
| Line 6: | Line 6: | ||
return "mw.smw module not found" | return "mw.smw module not found" | ||
end | end | ||
local dates = {} | |||
local peopleBirthDates = mw.smw.ask("[[Category:Person]]|?Person:Name|?Person:Date of birth") | local peopleBirthDates = mw.smw.ask("[[Category:Person]]|?Person:Name|?Person:Date of birth") | ||
local peopleDeathDates = mw.smw.ask("[[Category:Person]]|?Person:Name|?Person:Date of death") | local peopleDeathDates = mw.smw.ask("[[Category:Person]]|?Person:Name|?Person:Date of death") | ||
| Line 13: | Line 16: | ||
for num, row in pairs( peopleBirthDates ) do | for num, row in pairs( peopleBirthDates ) do | ||
dates[lang:formatDate("U", row["Person:Date of birth"])] = { | |||
row[row[0]] .. " was born" | |||
} | |||
end | end | ||
for num, row in pairs( peopleDeathDates ) do | for num, row in pairs( peopleDeathDates ) do | ||
dates[lang:formatDate("U", row["Person:Date of death"])] = { | |||
row[row[0]] .. " died" | |||
} | |||
end | end | ||
for num, row in pairs( compositionDates ) do | for num, row in pairs( compositionDates ) do | ||
dates[lang:formatDate("U", row["Composition:Date"])] = { | |||
row[row[0]] .. " was composed" | |||
} | |||
end | |||
for date, row in pairs( dates ) do | |||
for num, row2 in pairs( row ) do | |||
result = result .. row2[0] | |||
end | |||
end | end | ||
Revision as of 20:33, 10 November 2022
Documentation for this module may be created at Module:Timeline/doc
local p = {}
local lang = mw.language.new("en")
function p.render( frame )
if not mw.smw then
return "mw.smw module not found"
end
local dates = {}
local peopleBirthDates = mw.smw.ask("[[Category:Person]]|?Person:Name|?Person:Date of birth")
local peopleDeathDates = mw.smw.ask("[[Category:Person]]|?Person:Name|?Person:Date of death")
local compositionDates = mw.smw.ask("[[Category:Composition]]|?Person:Title|?Composition:Date")
local result = ""
for num, row in pairs( peopleBirthDates ) do
dates[lang:formatDate("U", row["Person:Date of birth"])] = {
row[row[0]] .. " was born"
}
end
for num, row in pairs( peopleDeathDates ) do
dates[lang:formatDate("U", row["Person:Date of death"])] = {
row[row[0]] .. " died"
}
end
for num, row in pairs( compositionDates ) do
dates[lang:formatDate("U", row["Composition:Date"])] = {
row[row[0]] .. " was composed"
}
end
for date, row in pairs( dates ) do
for num, row2 in pairs( row ) do
result = result .. row2[0]
end
end
return result
end
return p