It is currently April 27th, 2024, 5:44 am

[solved] Adding daily timer to a skin - shows more than 24 hours

Get help with creating, editing & fixing problems with skins
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

[solved] Adding daily timer to a skin - shows more than 24 hours

Post by CodeCode »

Hello, I have this countdown timer. I counts down to the same day and time every week. Then resets and continues to countdown to the next day and time. Here is the working parts of that (Yincognito helped me with this):

Code: Select all

[NDay]
Group=Time
Measure=Time
Format=%w

[ESec]
Group=Time
Measure=Calc
Formula=((604800+([NDay]-#TDay#)*86400+([NDay:Timestamp]%86400-(#THrs#*3600+#TMin#*60+#TSec#)))%604800)
MaxValue=604800
InvertMeasure=1
DynamicVariables=1

[Result]
Group=Time
Measure=Uptime
SecondsValue=[ESec]
Format=%4!02i! : %3!02i! : %2!02i! : %1!02i!
DynamicVariables=1
I works perfectly. I had originally had success but the day of week was returning incorrectly, but the above formula fixed that.
So I thought to have a daily countdown, that restarts once the target hour and minute was reached. This is my code for that:

Code: Select all

[TimeNow]
Measure=Time
Format=%H:%M:%S
IfConditionMode=1
DynamicVariables=1

[TimeTargeta]
Measure=Time
Format=%H:%M:%S
TimeStampFormat=%H:%M:%S
TimeStamp="#THrs1#:#TMin1#:#TSec1#"
DynamicVariables=1

[MeasureCalca]
Measure=Calc
Formula=([TimeNow:TimeStamp]%86400) - ([TimeTargeta:TimeStamp]%86400)
InvertMeasure=1
MaxValue=86400
DynamicVariables=1

[Resulta]
Measure=Uptime
SecondsValue=[MeasureCalca]
Format="%3!02i! : %2!02i! : %1!02i!"
Disabled=#ToggleA#
DynamicVariables=1
The problem is similar to my original problem. In this case the hours exceed the 24 maximum, until the target time is reached then it starts again at 23 hours 59 minutes and 59 seconds. I thought the above code was working but I added a Disabled=#Variable to the Resulta Measure. It looked good until I checked again today and when within the remaining 59 minutes and 59 seconds it actually flipped to 24 hours 59 minutes 59 seconds, instead of the hours being 0 or 00.

I tried to duplicate Yincognito's code to instead calculate #THrs1# to prevent that from happening, but it didnt seem to make a difference, or in other tries the clock somehow changed to 12 hour and not 24 hour.

Any help is appreciated. I know there is a formula, but my math is not as good as Yincognito's or any gurus in this forum.

I hope I posted enough code to go by. The skin has many personal information in it and I am avoiding making a copy that has none, but.. I will if that is needed.

Cheers
Last edited by CodeCode on September 24th, 2023, 4:11 am, edited 1 time in total.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Adding daily timer to a skin - shows more than 24 hours

Post by CodeCode »

Ok. I took another spin around using Yincognito's code for the weekly timer, and I think this time I got it right. The following seems to work:

Code: Select all

[TimeH]
Measure=Time
Format=%H
IfConditionMode=1
DynamicVariables=1

[TimeTargeta]
Measure=Time
Format=%H:%M:%S
TimeStampFormat=%H:%M:%S
TimeStamp="#THrs1#:#TMin1#:#TSec1#"
DynamicVariables=1

[MeasureCalca]
Measure=Calc
Formula=((86400+([TimeH]-#Thrs1#)*86400+(([TimeH:TimeStamp]%3600-(#Tmin1#*60+#Tsec1#))))%86400)
InvertMeasure=1
MaxValue=86400
DynamicVariables=1

[Resulta]
Measure=Uptime
SecondsValue=[MeasureCalca]
Format="%3!02i! : %2!02i! : %1!02i!"
Disabled=#ToggleA#
DynamicVariables=1
So it counts down to 00:00:01- it momentarily shows 24:00:00, instead of showing 00:00:00 but for now, I seem to have it going good for now.

If there is a way to get that 00:00:00 to show at t minus 0, I will continue to try and wrap my head around that.

Thanks Yincognito - you helped me again - even if passively - your help continues to assist my rainmeter hobby. :thumbup:

EDIT: I just realised that the 24:00:00 is time-o-graphically correct as during that second that is actually correct. :great:

EDIT2: This actually works: Formula=((86400+([TimeH]-#THrs1#)*3600+(([TimeH:TimeStamp]%3600-(#TMin1#*60+#Tsec1#))))%86400)
Otherwise it was tidally locked to the hour between t-minus 23 and 24 hours.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [solved] Adding daily timer to a skin - shows more than 24 hours

Post by Yincognito »

Glad you got it working (if you did, that is), you're getting better and better at it. ;-) Sorry for not replying here yet, but when I have time, my priority is always replying to pending topics I'm subscribed at first, and only then checking for new posts and handling them. Anyway, as you noticed, even when passive, my virtual presence can still help, lol.

I suspect the measure in your initial post could have been made to use something like:

Code: Select all

Formula=((86400+[TimeTargeta:TimeStamp]%86400-[TimeNow:TimeStamp]%86400)%86400)
InvertMeasure=0
and still work, for a count DOWN system. As you already noticed, adding the full interval before computing a modulo of a difference by that same interval is a simple way to always keep the result positive, even if the difference itself is negative.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
CodeCode
Posts: 1366
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: [solved] Adding daily timer to a skin - shows more than 24 hours

Post by CodeCode »

Yincognito wrote: September 24th, 2023, 11:35 pm Glad you got it working (if you did, that is), you're getting better and better at it. ;-) Sorry for not replying here yet, but when I have time, my priority is always replying to pending topics I'm subscribed at first, and only then checking for new posts and handling them. Anyway, as you noticed, even when passive, my virtual presence can still help, lol.

I suspect the measure in your initial post could have been made to use something like:

Code: Select all

Formula=((86400+[TimeTargeta:TimeStamp]%86400-[TimeNow:TimeStamp]%86400)%86400)
InvertMeasure=0
and still work, for a count DOWN system. As you already noticed, adding the full interval before computing a modulo of a difference by that same interval is a simple way to always keep the result positive, even if the difference itself is negative.
That does look more intuitive. I was getting mixed results when attempting something like you have shown above - in the department of the Hours going over 24 hours during the 00 hour of the day. So knowing your help with calculating the weekly timer, I turned to that, not even seeing the method of the math as you just pointed out.

I really appreciate the time you and other gurus spend helping so many people (and me of course lol).
Cheers to you Yincognito! :rosegift:
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [solved] Adding daily timer to a skin - shows more than 24 hours

Post by Yincognito »

CodeCode wrote: September 25th, 2023, 4:25 am So knowing your help with calculating the weekly timer, I turned to that, not even seeing the method of the math as you just pointed out.
No worries, both ways are just as valid, so you can use any of them you like more. 8-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth