Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1486

Lua Scripting • Re: Working with date / time in Lua

$
0
0
I did a little digging, and there is a way to get that [&MeasureName:Timestamp] value into Lua using the SELF: object with a custom option on the Lua script measure:

Skin:

Code:

[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1[Variables][MeasureTime]Measure=TimeFormat=%#c[MeasureLua]Measure=ScriptScriptFile=Test.luaWindowsTimestamp=[&MeasureTime:TimeStamp]DynamicVariables=1[MeterString]Meter=StringMeasureName=MeasureTimeMeasureName2=MeasureLuaFontColor=255,255,255,255FontSize=15SolidColor=0,0,0,1AntiAlias=1Text=%1 in Windows is %2 in Lua
Lua:

Code:

function Update()timestamp = SELF:GetNumberOption('WindowsTimestamp')unixTime = timestamp - 11644473600return (os.date("!%c", unixTime))end
2.jpg

Note that the ! prefix on the "format" first parameter of os.date tells it to treat the second parameter "value" as local time instead of UTC.

https://docs.rainmeter.net/manual/measures/script/#UserDefined
https://docs.rainmeter.net/manual/lua-scripting/#SelfObject
https://docs.rainmeter.net/manual/lua-scripting/#GetNumberOption

Statistics: Posted by jsmorley — Yesterday, 7:33 pm



Viewing all articles
Browse latest Browse all 1486

Trending Articles