Module:Upcoming Birthdays: Difference between revisions
From NOISZ Wiki
RiceEmpress (talk | contribs) No edit summary |
RiceEmpress (talk | contribs) mNo edit summary |
||
(62 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
local function sortBirthdays( a, b ) | local function sortBirthdays( a, b ) | ||
return a[2] | return a[2] < b[2] and b[2] > 0; | ||
end | end | ||
function p.main() | function p.main(frame) | ||
birthdays = {} | birthdays = {} | ||
birthdays[1] = {'Hikari Aoki',os.difftime(os.time{year=currentYear,month=01,day=22},currentDay)} | birthdays[1] = {'Hikari Aoki',os.difftime(os.time{year=currentYear,month=01,day=22},currentDay),'January 22nd'} | ||
birthdays[2] = {'Sera Hoshikawa',os.difftime(os.time{year=currentYear,month=03,day=14},currentDay)} | birthdays[2] = {'Sera Hoshikawa',os.difftime(os.time{year=currentYear,month=03,day=14},currentDay),'March 14th'} | ||
birthdays[3] = {'Grace Kamenashi',os.difftime(os.time{year=currentYear,month=04,day=01},currentDay)} | birthdays[3] = {'Grace Kamenashi',os.difftime(os.time{year=currentYear,month=04,day=01},currentDay),'April 1st'} | ||
birthdays[4] = {'Arietta Antiphon',os.difftime(os.time{year=currentYear,month=06,day=18},currentDay)} | birthdays[4] = {'Arietta Antiphon',os.difftime(os.time{year=currentYear,month=06,day=18},currentDay),'June 18th'} | ||
birthdays[5] = {'Joker',os.difftime(os.time{year=currentYear,month=06,day=18},currentDay)} | birthdays[5] = {'Joker',os.difftime(os.time{year=currentYear,month=06,day=18},currentDay),'June 18th'} | ||
birthdays[6] = {'Asuka Fujita',os.difftime(os.time{year=currentYear,month=07,day=30},currentDay)} | birthdays[6] = {'Asuka Fujita',os.difftime(os.time{year=currentYear,month=07,day=30},currentDay),'July 30th'} | ||
birthdays[7] = {'Sumire Hitori',os.difftime(os.time{year=currentYear,month=09,day=09},currentDay)} | birthdays[7] = {'Sumire Hitori',os.difftime(os.time{year=currentYear,month=09,day=09},currentDay),'September 9th'} | ||
birthdays[8] = {'Hitori',os.difftime(os.time{year=currentYear,month=09,day=09},currentDay)} | birthdays[8] = {'Hitori',os.difftime(os.time{year=currentYear,month=09,day=09},currentDay),'September 9th'} | ||
birthdays[9] = {'Hakuno Nekoda',os.difftime(os.time{year=currentYear,month=12,day=25},currentDay)} | birthdays[9] = {'Hakuno Nekoda',os.difftime(os.time{year=currentYear,month=12,day=25},currentDay),'December 25th'} | ||
birthdays[10] = {'Shion Nekoda',os.difftime(os.time{year=currentYear,month=12,day=29},currentDay)} | birthdays[10] = {'Shion Nekoda',os.difftime(os.time{year=currentYear,month=12,day=29},currentDay),'December 29th'} | ||
birthdays[11] = {'Hikari Aoki',os.difftime(os.time{year=currentYear+1,month=01,day=22},currentDay)} | birthdays[11] = {'Hikari Aoki',os.difftime(os.time{year=currentYear+1,month=01,day=22},currentDay),'January 22nd'} | ||
birthdays[12] = {'Sera Hoshikawa',os.difftime(os.time{year=currentYear+1,month=03,day=14},currentDay)} | birthdays[12] = {'Sera Hoshikawa',os.difftime(os.time{year=currentYear+1,month=03,day=14},currentDay),'March 14th'} | ||
birthdays[13] = {'Grace Kamenashi',os.difftime(os.time{year=currentYear+1,month=04,day=01},currentDay),'April 1st'} | |||
table.sort(birthdays, sortBirthdays) | table.sort(birthdays, sortBirthdays) | ||
local numBirthdays = 0 | |||
local birthdayString = '' | |||
local galleryChars = {} | |||
for k, v in pairs(birthdays) do | |||
if v[2] > 0 and numBirthdays < 3 and v[2] then | |||
numBirthdays = numBirthdays + 1 | |||
galleryChars[numBirthdays] = v[1] | |||
birthdayString = birthdayString .. v[3] .. ' - [[' .. v[1] .. ']] (' ..math.ceil(v[2]/86400) .. ' days) <br/>' | |||
end | |||
end | |||
return frame:expandTemplate{ title ='SL Story Gallery', args = {spacerheight='0px', char1 = galleryChars[1], char2 = galleryChars[2], char3 = galleryChars[3]}} .. birthdayString | |||
end | end | ||
return p | return p |
Latest revision as of 13:24, 29 September 2025
Documentation for this module may be created at Module:Upcoming Birthdays/doc
local capiunto = require 'capiunto' local lang = mw.language.getContentLanguage() local currentYear = lang:formatDate("Y") local currentDay = os.time() local p = {} local function sortBirthdays( a, b ) return a[2] < b[2] and b[2] > 0; end function p.main(frame) birthdays = {} birthdays[1] = {'Hikari Aoki',os.difftime(os.time{year=currentYear,month=01,day=22},currentDay),'January 22nd'} birthdays[2] = {'Sera Hoshikawa',os.difftime(os.time{year=currentYear,month=03,day=14},currentDay),'March 14th'} birthdays[3] = {'Grace Kamenashi',os.difftime(os.time{year=currentYear,month=04,day=01},currentDay),'April 1st'} birthdays[4] = {'Arietta Antiphon',os.difftime(os.time{year=currentYear,month=06,day=18},currentDay),'June 18th'} birthdays[5] = {'Joker',os.difftime(os.time{year=currentYear,month=06,day=18},currentDay),'June 18th'} birthdays[6] = {'Asuka Fujita',os.difftime(os.time{year=currentYear,month=07,day=30},currentDay),'July 30th'} birthdays[7] = {'Sumire Hitori',os.difftime(os.time{year=currentYear,month=09,day=09},currentDay),'September 9th'} birthdays[8] = {'Hitori',os.difftime(os.time{year=currentYear,month=09,day=09},currentDay),'September 9th'} birthdays[9] = {'Hakuno Nekoda',os.difftime(os.time{year=currentYear,month=12,day=25},currentDay),'December 25th'} birthdays[10] = {'Shion Nekoda',os.difftime(os.time{year=currentYear,month=12,day=29},currentDay),'December 29th'} birthdays[11] = {'Hikari Aoki',os.difftime(os.time{year=currentYear+1,month=01,day=22},currentDay),'January 22nd'} birthdays[12] = {'Sera Hoshikawa',os.difftime(os.time{year=currentYear+1,month=03,day=14},currentDay),'March 14th'} birthdays[13] = {'Grace Kamenashi',os.difftime(os.time{year=currentYear+1,month=04,day=01},currentDay),'April 1st'} table.sort(birthdays, sortBirthdays) local numBirthdays = 0 local birthdayString = '' local galleryChars = {} for k, v in pairs(birthdays) do if v[2] > 0 and numBirthdays < 3 and v[2] then numBirthdays = numBirthdays + 1 galleryChars[numBirthdays] = v[1] birthdayString = birthdayString .. v[3] .. ' - [[' .. v[1] .. ']] (' ..math.ceil(v[2]/86400) .. ' days) <br/>' end end return frame:expandTemplate{ title ='SL Story Gallery', args = {spacerheight='0px', char1 = galleryChars[1], char2 = galleryChars[2], char3 = galleryChars[3]}} .. birthdayString end return p