It is currently April 19th, 2024, 11:37 am

[Feature] MinValue, MaxValue and Percent for Time measure section variables

Report bugs with the Rainmeter application and suggest features.
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

[Feature] MinValue, MaxValue and Percent for Time measure section variables

Post by Yincognito »

Sample skin:

Code: Select all

[Variables]
Time=2020-02-21 12:00:00

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

---Measures---

[Time]
Measure=Time
TimeStamp=#Time#
TimeStampFormat=%Y-%m-%d %H:%M:%S
Format=%Y-%m-%d %H:%M:%S
TimeZone=0
DaylightSavingTime=0
UpdateDivider=-1
DynamicVariables=1

[Year]
Measure=Time
TimeStamp=([Time:Timestamp])
Format=%Y
TimeZone=0
DaylightSavingTime=0
UpdateDivider=-1
DynamicVariables=1

[Month]
Measure=Time
TimeStamp=([Time:Timestamp])
Format=%m
TimeZone=0
DaylightSavingTime=0
UpdateDivider=-1
DynamicVariables=1

[Day]
Measure=Time
TimeStamp=([Time:Timestamp])
Format=%d
TimeZone=0
DaylightSavingTime=0
UpdateDivider=-1
DynamicVariables=1

[Hour]
Measure=Time
TimeStamp=([Time:Timestamp])
Format=%H
TimeZone=0
DaylightSavingTime=0
UpdateDivider=-1
DynamicVariables=1

[Minute]
Measure=Time
TimeStamp=([Time:Timestamp])
Format=%M
TimeZone=0
DaylightSavingTime=0
UpdateDivider=-1
DynamicVariables=1

[Second]
Measure=Time
TimeStamp=([Time:Timestamp])
Format=%S
TimeZone=0
DaylightSavingTime=0
UpdateDivider=-1
DynamicVariables=1

---Meters---

[TimeText]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="Year  = [Year], YearMax = [Year:MaxValue], YearPercent = [Year:%]#CRLF#Month  = [Month], MonthMax = [Month:MaxValue], MonthPercent = [Month:%]#CRLF#Day  = [Day], DayMax = [Day:MaxValue], DayPercent = [Day:%]#CRLF#Hour  = [Hour], HourMax = [Hour:MaxValue], HourPercent = [Hour:%]#CRLF#Minute  = [Minute], MinuteMax = [Minute:MaxValue], MinutePercent = [Minute:%]#CRLF#Second  = [Second], SecondMax = [Second:MaxValue], SecondPercent = [Second:%]"
UpdateDivider=-1
DynamicVariables=1
Wouldn't be both nice AND useful to have either the Min / Max Values, the percentual values, or even better have both parameters of the corresponding section variables been automatically set by Rainmeter to the correct values according to leap years and all that, instead of going to great lengths to calculate them in additional code? For example, the [Day:MaxValue] would be in this case 29, since 2020 was a leap year and the month here is February, and the [Day:%] would be 21 / 29 = 0.72 = 72 % accordingly. Naturally, do the same for year, month, hour, minute and second, as I suppose Windows APIs and programming languages provide easy to use functions to get those (the max timestamp date on my Win 10 computer is 31 Dec 9999 23:59:59, if it matters).

Also, in a similar fashion, having the MaxValue of day of year properly set to either 365 or 366 would be an asset:

Code: Select all

[DayOfYear]
Measure=Time
TimeStamp=([Time:Timestamp])
Format=%j
TimeZone=0
DaylightSavingTime=0
UpdateDivider=-1
DynamicVariables=1
since folks could then do stuff like [!SetVariable DayOfYear (([DayOfYear:MaxValue]+[DayOfYear]+#IncrementOrDecrementStep#)%[DayOfYear:MaxValue])] or similar (some -1 and +1 additions to the fomula here are required due to days of year going from 1 to 365 or 366 instead of 0 to 364 or 365, but you get the idea), in order to go through the desired interval, in this case the days of that year.

P.S. Currently, those :MaxValue and :% values are either 0, 1 or 100, so they basically don't have a max whatsoever. Comparing this to other Rainmeter places where these 2 parameters are automatically and properly set gives one a hint of the usefulness of the idea.

EDIT: Just realized that the implementation of this feature would depend on whether the timestamp of Time measures is the "real" number value to which MaxValue and % apply to, or is just a somewhat "separate entity" internally. If the former, maybe some conversion to user readable values could be done in practice (i.e. when getting [Day:MaxValue] and such values) or the log? :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: [Feature] MinValue, MaxValue and Percent for Time measure section variables

Post by death.crafter »

When you could literally make a lua script?
from the Realm of Death
User avatar
David8192
Posts: 246
Joined: July 8th, 2021, 11:30 pm
Location: The King's Avenue, Golden Kingdom

Re: [Feature] MinValue, MaxValue and Percent for Time measure section variables

Post by David8192 »

death.crafter wrote: November 15th, 2021, 4:45 pm When you could literally make a lua script?
:lol: :D :welcome: :Whistle
I was just thinking :???:

d.c, you could change your name to l.c
lua.crafter :rolmfao:
the DA GALLERY 8-) For some Reason, the square root of X2 does not involve X
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Feature] MinValue, MaxValue and Percent for Time measure section variables

Post by Yincognito »

death.crafter wrote: November 15th, 2021, 4:45 pm When you could literally make a lua script?
Well, you could make a script for pretty much everything, of course - but then I'd rather move my entire process to some fully fledged programming language (not even Lua since it only has the scripting part) and forget about Rainmeter, right? :confused: At least that's how I see it - if I'm going to travel from Paris to Athens, I'd rather take a flight from one to the other, instead of driving from Paris to Vienna and then taking the train from Vienna to Athens. I'm not a fan of using a thousand things for a single objective, especially if the objective is simple enough, but you already know that, LOL.

Anyway, it was just a suggestion, to avoid further coding (in native Rainmeter OR Lua). A script, while solving the issue, does require additional coding, just like a couple of equivalent native Rainmeter measures would, so you end up doing the avoidable extra work anyway... :???:

P.S. That being said, Lua scripting is a possibility I keep as a plan B for the whole process. I'm just not at the point of making the switch yet, and it's unlikely I would have to - these things aren't THAT complex to require scripting.
David8192 wrote: November 15th, 2021, 8:41 pm :lol: :D :welcome: :Whistle
I was just thinking :???:

d.c, you could change your name to l.c
lua.crafter :rolmfao:
Or Craft.Lua.To.Death... :lol: It's understandable though, he's like me and regexes, hahaha! Not much difference between script and string manipulation - you understand everything while others look at the result like it came from Mars. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
David8192
Posts: 246
Joined: July 8th, 2021, 11:30 pm
Location: The King's Avenue, Golden Kingdom

Re: [Feature] MinValue, MaxValue and Percent for Time measure section variables

Post by David8192 »

Yincognito wrote: November 15th, 2021, 9:22 pm Or Craft.Lua.To.Death... :lol: It's understandable though, he's like me and regexes, hahaha! Not much difference between script and string manipulation - you understand everything while others look at the result like it came from Mars. ;-)
:rofl: That's a good one! Problem is, he is getting me interested. Though, once I get a hang of it, I would like to use it for some of those solutions from Mars. Yeah, and regexes still look like magic.
the DA GALLERY 8-) For some Reason, the square root of X2 does not involve X
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Feature] MinValue, MaxValue and Percent for Time measure section variables

Post by Yincognito »

David8192 wrote: November 15th, 2021, 9:36 pm :rofl: That's a good one! Problem is, he is getting me interested. Though, once I get a hang of it, I would like to use it for some of those solutions from Mars. Yeah, and regexes still look like magic.
Well, if he's getting you interested, he certainly does a good job at promoting scripting. :great: Obviously, you'd only have to gain from becoming proficient in either Lua or regex, and I'm the first to support self improvement.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: [Feature] MinValue, MaxValue and Percent for Time measure section variables

Post by death.crafter »

Yincognito wrote: November 15th, 2021, 10:14 pm Well, if he's getting you interested, he certainly does a good job at promoting scripting. :great: Obviously, you'd only have to gain from becoming proficient in either Lua or regex, and I'm the first to support self improvement.
Tbh, you'd gain more from regex since it comes in handy no matter which language you're using.

Anyway, I thought your objective was shorter code. So, I said lua, since I feel what you're suggesting for is a bit much out of scope for time measure. But let's wait for the devs.

Btw, how is the pain in your tooth now? All good? I hope so.
David8192 wrote: November 15th, 2021, 8:41 pm :lol: :D :welcome: :Whistle
I was just thinking :???:

d.c, you could change your name to l.c
lua.crafter :rolmfao:
Wish I could, but there is no nick name system in the forums :lol:
from the Realm of Death
User avatar
David8192
Posts: 246
Joined: July 8th, 2021, 11:30 pm
Location: The King's Avenue, Golden Kingdom

Re: [Feature] MinValue, MaxValue and Percent for Time measure section variables

Post by David8192 »

Yincognito wrote: November 15th, 2021, 10:14 pm Well, if he's getting you interested, he certainly does a good job at promoting scripting. :great: Obviously, you'd only have to gain from becoming proficient in either Lua or regex, and I'm the first to support self improvement.
Indeed. As soon as I become a little confident with regex, I will look into it. I also need to get some python along the way.
the DA GALLERY 8-) For some Reason, the square root of X2 does not involve X
User avatar
David8192
Posts: 246
Joined: July 8th, 2021, 11:30 pm
Location: The King's Avenue, Golden Kingdom

Re: [Feature] MinValue, MaxValue and Percent for Time measure section variables

Post by David8192 »

death.crafter wrote: November 15th, 2021, 10:22 pm Wish I could, but there is no nick name system in the forums :lol:
:rosegift:
the DA GALLERY 8-) For some Reason, the square root of X2 does not involve X
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Feature] MinValue, MaxValue and Percent for Time measure section variables

Post by Yincognito »

death.crafter wrote: November 15th, 2021, 10:22 pmAnyway, I thought your objective was shorter code. So, I said lua, since I feel what you're suggesting for is a bit much out of scope for time measure. But let's wait for the devs.
What I posted was just an example to illustrate how the :MaxValue and :% parameters are unused in the Time measures, it's not my actual code, where such a feature will shorten it since I wouldn't have to compute or write other measures to get, say, the maximum value a day of a certain month can have. It would be as simple as using [Day:MaxValue] (where [Day] is assumed to include a Format=%d option) if Rainmeter would set MaxValue automatically.

I'm not sure what you mean with it being out of scope, since, for example, FreeDiskSpace measures do have a range from 0 to the actual total size of the measured disk resource, and my suggestion is simply to have the equivalent system for Time measures, if possible.
death.crafter wrote: November 15th, 2021, 10:22 pmBtw, how is the pain in your tooth now? All good? I hope so.
The pain and the swelling is gone, but it's the potential danger of becoming infected again which is the main reason for wanting to remove it. Getting rid of it should in theory eliminate that risk. The removal would probably be a bit difficult since the tooth doesn't wobble yet, despite having a cavity.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth