Test.ini:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
[LuaBirthday]
Measure=Script
ScriptFile=Test.lua
UpdateDivider=3600
[MeterBirthday]
Meter=String
MeasureName=LuaBirthday
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Code: Select all
Jan 25,1940,Diane Smith
Jan 30,1932,Gladys Hinz
Oct 15,1960,Some Person
Feb 26,1990,William Morley
Mar 6,1967,Norma Morley
Apr 14,1966,Bob Morley
Apr 25,1954,Jeffrey Morley
May 17,1988,Elizabeth Morley
May 18,2004,Daniel Attis
May 31,1957,John Morley
Aug 11,1923,Elinor Morley
Aug 29,1986,Catherine Morley
Nov 4,1992,Christina Morley
Nov 14,1946,Linda Morley
Dec 13,1946,Brad Morley
Code: Select all
function Initialize()
filePath = SKIN:MakePathAbsolute('Birthdays.csv')
birthdayArray = {}
for line in io.lines(filePath) do
dateValue, yearValue, personName = line:match('%s*(.-),%s*(.-),%s*(.-)$')
birthdayArray[#birthdayArray + 1] = { dateValue=dateValue, yearValue=yearValue, personName=personName }
end
end
function Update()
todayString = os.date('%b %d')
todayString = todayString:gsub('.-%s(0)','')
yearNow = os.date('%Y')
for inc = 1, #birthdayArray do
if birthdayArray[inc]['dateValue'] == todayString then
ageValue = tonumber(yearNow) - tonumber(birthdayArray[inc]['yearValue'])
return birthdayArray[inc]['personName']..' is '..ageValue..' years old today'
end
end
return 'None'
end
Note that I'm using gsub to strip off any leading zeros on the current day of the month.
This is going to return the first matching birthday. I will leave it to you to figure out how to handle twins...