It is currently March 28th, 2024, 1:07 pm

meter to display min/mins

Get help with creating, editing & fixing problems with skins
Post Reply
chow69
Posts: 3
Joined: June 7th, 2021, 12:05 pm

meter to display min/mins

Post by chow69 »

I am very new here....
straight to my problem
I have a measure that returns numbers in minutes:

[MeasureDiffInMinutes]
Measure=Calc
Group=ConvertlastTimeStateChanged
Formula=(Floor(([mDateTimeNow:TimeStamp]-[dtlastTimeStateChanged:TimeStamp])/60))
Disabled=1
DynamicVariables=1

#note: dtlastTimeStateChanged is a webparser child measure, I used [!EnableMeasureGroup ConvertlastTimeStateChanged][!UpdateMeasureGroup ConvertlastTimeStateChanged] to update this measure at the parent webparser

this measure works fine. My problem is I like to have a meter that displays in the following format
if value = 0 -> <empty string>
if value = 1 -> "1 min."
if value > 1 and < 60 -> [MeasureDiffInMinutes] mins.
if value > 60 -> H:MM hrs.

any help is much appreciated. has been working on this Meter for days
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: meter to display min/mins

Post by jsmorley »

Perhaps something like this:

Code: Select all

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

[Variables]
FakeSeconds = 34837

[MeasureMinutes]
Measure=Calc
Formula=(Floor(#FakeSeconds# / 60))
IfCondition=MeasureMinutes = 0
IfTrueAction=[!SetOption MeasureFormatTime Format " "]
IfCondition2=(MeasureMinutes = 1)
IfTrueAction2=[!SetOption MeasureFormatTime Format "%2!i! min"]
IfCondition3=(MeasureMinutes > 1) && (MeasureMinutes < 60)
IfTrueAction3=[!SetOption MeasureFormatTime Format "%2!i! mins"]
IfCondition4=MeasureMinutes >= 60
IfTrueAction4=[!SetOption MeasureFormatTime Format "%3!i!:%2!i! hrs"]

[MeasureFormatTime]
Measure=Uptime
SecondsValue=([MeasureMinutes] * 60)
DynamicVariables=1

[MeterDisplayTime]
Meter=String
MeasureName=MeasureFormatTime
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
https://docs.rainmeter.net/manual/measures/uptime/


1.jpg
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: meter to display min/mins

Post by death.crafter »

chow69 wrote: June 7th, 2021, 12:19 pm I am very new here....
straight to my problem
I have a measure that returns numbers in minutes:

[MeasureDiffInMinutes]
Measure=Calc
Group=ConvertlastTimeStateChanged
Formula=(Floor(([mDateTimeNow:TimeStamp]-[dtlastTimeStateChanged:TimeStamp])/60))
Disabled=1
DynamicVariables=1

#note: dtlastTimeStateChanged is a webparser child measure, I used [!EnableMeasureGroup ConvertlastTimeStateChanged][!UpdateMeasureGroup ConvertlastTimeStateChanged] to update this measure at the parent webparser

this measure works fine. My problem is I like to have a meter that displays in the following format
if value = 0 -> <empty string>
if value = 1 -> "1 min."
if value > 1 and < 60 -> [MeasureDiffInMinutes] mins.
if value > 60 -> H:MM hrs.

any help is much appreciated. has been working on this Meter for days
We need to see the whole code and preferably an attached skin to know what is actually going on. Personally I can't understand what you are aiming for.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: meter to display min/mins

Post by jsmorley »

death.crafter wrote: June 7th, 2021, 12:43 pm We need to see the whole code and preferably an attached skin to know what is actually going on. Personally I can't understand what you are aiming for.
I think his problem is reasonably straight-forward. He wants to turn some number of minutes into a formatted string that is different depending on the number of minutes. The UpTime measure is probably the simplest way to attack this, as demonstrated in my post above yours.

We need to divide the seconds by 60, which he is already doing, to get it into the form he wants to use for the IfConditions, then back to seconds to use in the UpTime Measure, which is always based on seconds.

The only thing I didn't do exactly to his request was to set an "empty" string when the number is zero. The way !SetOption works is that setting an option to "" or an empty string, in effect just removes the option entirely, and with the Format command in UpTime, that will cause it to use the default Format, which isn't what he wants. So I set the option to a single space instead. Actually setting the option to an empty string is not possible, and you would instead want to hide the meter or remove the MeasureName option, which would be a bit more complicated.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: meter to display min/mins

Post by death.crafter »

jsmorley wrote: June 7th, 2021, 12:49 pm I think his problem is reasonably straight-forward. He wants to turn some number of minutes into a formatted string that is different depending on the number of minutes. The UpTime measure is probably the most simple way to attack this, as demonstrated in my post above yours.

We need to divide the seconds by 60, which he is already doing, to get it into the form he wants to use for the IfConditions, then back to seconds to use in the UpTime Measure, which is always based on seconds.

This is based on his specific request, but it should be noted that it won't be terribly precise, since it does not account for fractions of a minute.
Actually I realized you posted a solution right after posting the reply. It should be a feature to delete replies if not posts, don't you think?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: meter to display min/mins

Post by jsmorley »

death.crafter wrote: June 7th, 2021, 1:03 pm Actually I realized you posted a solution right after posting the reply. It should be a feature to delete replies if not posts, don't you think?
It does warn you if you are about to submit a post when a reply has been added since you started creating the post. phpBB won't let you delete a post if there are any posts that come after it in the thread. This is reasonable behavior, so you don't end up with a lot of mysterious answers to missing questions and such. You can edit your post and just have it say "Never mind" or whatever, but it will then notify everyone that your post was in fact edited, which will protect from having people try to re-write history or in effect put inappropriate words in other peoples mouths. Once someone has asked "Is the sky blue" and gotten and answer of "Yes!", it wouldn't be good to allow them to transparently change the question to "Are you an idiot?" after the fact.
chow69
Posts: 3
Joined: June 7th, 2021, 12:05 pm

Re: meter to display min/mins

Post by chow69 »

jsmorley wrote: June 7th, 2021, 12:49 pm I think his problem is reasonably straight-forward. He wants to turn some number of minutes into a formatted string that is different depending on the number of minutes. The UpTime measure is probably the simplest way to attack this, as demonstrated in my post above yours.

We need to divide the seconds by 60, which he is already doing, to get it into the form he wants to use for the IfConditions, then back to seconds to use in the UpTime Measure, which is always based on seconds.

The only thing I didn't do exactly to his request was to set an "empty" string when the number is zero. The way !SetOption works is that setting an option to "" or an empty string, in effect just removes the option entirely, and with the Format command in UpTime, that will cause it to use the default Format, which isn't what he wants. So I set the option to a single space instead. Actually setting the option to an empty string is not possible, and you would instead want to hide the meter or remove the MeasureName option, which would be a bit more complicated.
thanks @jsmorley. this is exactly what I mean and want. the meter displays 2 measures actually; the last "state" [measure] and this number in mins or in hrs (>60). thank you very much. would try your above answer!!!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: meter to display min/mins

Post by jsmorley »

chow69 wrote: June 7th, 2021, 11:47 pm thanks @jsmorley. this is exactly what I mean and want. the meter displays 2 measures actually; the last "state" [measure] and this number in mins or in hrs (>60). thank you very much. would try your above answer!!!
Great...
chow69
Posts: 3
Joined: June 7th, 2021, 12:05 pm

Re: meter to display min/mins

Post by chow69 »

chow69 wrote: June 7th, 2021, 11:47 pm thanks @jsmorley. this is exactly what I mean and want. the meter displays 2 measures actually; the last "state" [measure] and this number in mins or in hrs (>60). thank you very much. would try your above answer!!!
sharing my result! thanks again to @jsmorley https://forum.rainmeter.net/memberlist.php?mode=viewprofile&u=85, the skin is completed.

Image

Image

you can see why I needed the empty string. and the design behind all this.

got to learn new measure - Uptime !!!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: meter to display min/mins

Post by jsmorley »

Nice work!
Post Reply