I kinda thought the Uptime formatting today is a bit geeky, and figured it would be nice to have a variant that allows for "Restarted on / at" instead of "Up for".
The output can be formatted using the same codes from Measure=Time.
It is currently December 1st, 2023, 6:39 am
Formatted Uptime skin
-
- Developer
- Posts: 22593
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Formatted Uptime skin
You do not have the required permissions to view the files attached to this post.
-
- Posts: 608
- Joined: February 7th, 2011, 7:27 pm
- Location: Thessaloniki, GR
Re: Formatted Uptime skin
When I clicked to download the skin, I was thinking "boy, he must have done very complicated stuff to match the format from the Time measure to the os.date function". I was amazed to find out that both work with the same formatting codes.
This, to me, is one more proof of how professionally Rainmeter is developed. Well done to everyone.
Going back on topic, another great lua example Jeff. Getting script options, parsing them, making the user decide the output and returning it through the measure, in a few lines of code. Consider commenting it and adding it in the Lua tutorials.
This, to me, is one more proof of how professionally Rainmeter is developed. Well done to everyone.
Going back on topic, another great lua example Jeff. Getting script options, parsing them, making the user decide the output and returning it through the measure, in a few lines of code. Consider commenting it and adding it in the Lua tutorials.

-
- Developer
- Posts: 22593
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Formatted Uptime skin
Thanks,
There are two little "gotchas" I deal with in the Lua. The first is that Measure=Time uses a "#" format option in the string to remove leading zeros. That is not supported in the standard C strftime function used by Lua. So I have to play a little trick where I switch "%#" to "#%" so I can allow the user to format the string with the Measure=Time codes and not have Lua/Rainmeter blow up. Then I can use the # char to find and remove leading zeros.
The second is that the "%" char in Lua is a "magic escape" that to use as a literal must be escaped with itself, thus the sFormat = string.gsub(SELF:GetOption('Format'), '%%#', '#%%') construct when I "switch" the # and % chars.
Other than that, it is all pretty simple and straightforward.
There are two little "gotchas" I deal with in the Lua. The first is that Measure=Time uses a "#" format option in the string to remove leading zeros. That is not supported in the standard C strftime function used by Lua. So I have to play a little trick where I switch "%#" to "#%" so I can allow the user to format the string with the Measure=Time codes and not have Lua/Rainmeter blow up. Then I can use the # char to find and remove leading zeros.
The second is that the "%" char in Lua is a "magic escape" that to use as a literal must be escaped with itself, thus the sFormat = string.gsub(SELF:GetOption('Format'), '%%#', '#%%') construct when I "switch" the # and % chars.
Other than that, it is all pretty simple and straightforward.
-
- Posts: 608
- Joined: February 7th, 2011, 7:27 pm
- Location: Thessaloniki, GR
Re: Formatted Uptime skin
I had noticed the replacements, but I didn't understand they played such a big role. It is a genious little trick.
-
- Developer
- Posts: 22593
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Formatted Uptime skin
Skin in first post vastly simplified thanks to Smurfier remembering that Measure=Time returns a number of elapsed seconds in the "number" value by default...
Re: Formatted Uptime skin
that's pretty cool.
it would be even nicer in a webparser skin. so a news item could display "five minutes ago" instead of the actual publish time.
it would be even nicer in a webparser skin. so a news item could display "five minutes ago" instead of the actual publish time.
-
- Developer
- Posts: 1721
- Joined: July 25th, 2009, 4:47 am
Re: Formatted Uptime skin
Working on it. :)Alex Becherer wrote:that's pretty cool.
it would be even nicer in a webparser skin. so a news item could display "five minutes ago" instead of the actual publish time.
-
- Developer
- Posts: 22593
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Formatted Uptime skin
Actually not that hard, I have several skins that do that now. Difficult to make it "generic" for any feed though. The problem is that there are just tons of ways that <Pubdate> or whatever you use can be formatted, and taking daylight savings time into consideration can be a tad complicated.Alex Becherer wrote:that's pretty cool.
it would be even nicer in a webparser skin. so a news item could display "five minutes ago" instead of the actual publish time.
So unless you want to have a HUGE function to try to "figure out" date formats and timezones, you need to get the date format of the feed and customize a bit.
Here is an example of one that works nice:
You do not have the required permissions to view the files attached to this post.