Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,1
[Variables]
MyBirthday=April 25, 1974
[MeasureScript]
Measure=Script
ScriptFile=Birthday.lua
UpdateDivider=-1
[MeterAge]
Meter=String
FontFace=Fira Sans
FontSize=12
FontWeight=400
FontColor=215,239,252,255
AntiAlias=1
DynamicVariables=1
InlineSetting=Color | 137,209,250
InlinePattern=#MyAge#
Text=You are #MyAge# years old.
[MeterBirthday]
Meter=String
FontFace=Fira Sans
X=([MeterAge:X]+[MeterAge:W]+10)
Y=0r
FontSize=12
FontWeight=400
FontColor=215,239,252,255
AntiAlias=1
DynamicVariables=1
InlineSetting=Color | 137,209,250
InlinePattern=Birthday!
Text=Today is your Birthday!
Hidden=1
[MeterNext]
Meter=String
Group=Next
X=([MeterAge:X]+[MeterAge:W]+10)
Y=0r
FontFace=Fira Sans
FontSize=12
FontWeight=400
FontColor=215,239,252,255
AntiAlias=1
DynamicVariables=1
InlineSetting=Color | 137,209,250
InlinePattern=#NextBirtday#
Text=Your next birthday is on #NextBirtday#,
[MeterDays]
Meter=String
Group=Next
X=5R
Y=0r
FontFace=Fira Sans
FontSize=12
FontWeight=400
FontColor=215,239,252,255
AntiAlias=1
DynamicVariables=1
InlineSetting=Color | 137,209,250
InlinePattern=#DaysTil#
Text=in #DaysTil# days.
Code: Select all
function Initialize()
dofile(SKIN:GetVariable('@')..'date\\date.lua')
end
function Update()
myBirthday = SKIN:GetVariable('MyBirthday')
myDate = date(myBirthday)
myYear, myMonth, myDay = myDate:getdate()
currentDate = date()
currentYear, currentMonth, currentDay = currentDate:getdate()
myAge = math.floor(date.diff(currentDate, myDate):spandays() / 365)
if date(currentYear, myMonth, myDay) >= currentDate then
nextBirthday = date(currentYear, myMonth, myDay):fmt('%A, %B %d, %Y')
else
nextBirthday = date(currentYear+1, myMonth, myDay):fmt('%A, %B %d, %Y')
end
daysTilBirthday = math.abs(math.ceil(date.diff(nextBirthday, currentDate):spandays()))
SKIN:Bang('!SetVariable', 'MyAge', myAge)
SKIN:Bang('!SetVariable', 'NextBirtday', nextBirthday)
SKIN:Bang('!SetVariable', 'DaysTil', daysTilBirthday)
if daysTilBirthday > 0 then
SKIN:Bang('!SetOptionGroup', 'Next', 'Hidden', '0')
SKIN:Bang('!SetOption', 'MeterBirthday', 'Hidden', '1')
else
SKIN:Bang('!SetOptionGroup', 'Next', 'Hidden', '1')
SKIN:Bang('!SetOption', 'MeterBirthday', 'Hidden', '0')
end
end
1) Using dofile() in Lua to load an external library of Lua code to call and use in your script.
2) The date.lua library, which has some exceptional date / time handling that you can use.
The date.lua library is included with the skin, and can be found in @Resources\date\ in the skin after you install it.
The documentation for date.lua is at:
http://tieske.github.io/date/
Note: This uses a date.lua designed for Lua version 5.1. There is a version out there that is changed to target Lua version 5.2, but we have not implemented the 5.2 or the new 5.3.4 version of Lua in Rainmeter, due to possible backwards compatibility issues. So use the date.lua I have included, and not one you download from the web.