It is currently August 20th, 2019, 3:09 pm

Using the Uptime measure to format seconds

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
jsmorley
Developer
Posts: 19357
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Using the Uptime measure to format seconds

jsmorley » June 11th, 2017, 1:43 pm

While it can be tempting to jump to using a Lua function to convert a number of seconds, perhaps returned by some Time measure, into a formatted string of days, hours, minutes, seconds, there is a way using the Uptime measure native to Rainmeter that can work pretty well with a bit less effort.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureSeconds]
Measure=Calc
Formula=86401

[MesureFormatSeconds]
Measure=UpTime
SecondsValue=[MeasureSeconds]
Format="%4!i! days %3!i! hours %2!i! minutes %1!i! seconds"
RegExpSubstitute=1
Substitute="^1 days":"1 day"," 1 hours":" 1 hour"," 1 minutes":" 1 minute"," 1 seconds":" 1 second"
DynamicVariables=1

[MeterOutput]
Meter=String
MeasureName=MesureFormatSeconds
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
1.png
You do not have the required permissions to view the files attached to this post.