It is currently September 21st, 2020, 4:18 am

Looping countdown to specific hour

Help with creating, editing & fixing problems with skins
User avatar
Halloyo
Posts: 31
Joined: June 17th, 2020, 3:08 am

Looping countdown to specific hour

Post by Halloyo »

Hello,

I remember seeing this having been asked before somewhere, but I cannot for the life of me remember where. Anyway, is there a way to create a looping countdown to a specific hour? My specific use case is for game server time reset. For me, the game resets at 11am and I would like an infinitely looping countdown to that time.

I know there are countdown skins (like the one by themagnumizer), but that one doesn't loop for dates and I wouldn't even know how to begin to make it loop.
Last edited by Halloyo on June 28th, 2020, 9:29 pm, edited 1 time in total.
Pflosch
Posts: 27
Joined: May 24th, 2020, 7:04 am

Re: Looping countdown to specific hour

Post by Pflosch »

Something like that?

Code: Select all

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

[Variables]
ElevenToday=0

[m1]
measure=time
DynamicVariables=1
Timestamp=#ElevenToday#
TimestampFormat=%Y-%#m-%d %H:%M:%S
Format=%F

[m2]
measure=time

[m3]
measure=calc
DynamicVariables=1
Formula=[m1:timestamp]-[m2:timestamp]

[m4]
measure=time
DynamicVariables=1
Format=%F
OnUpdateAction=[!setVariable ElevenToday "[m4] 23:00:00"]

[m5]
measure=time
DynamicVariables=1
Timestamp=[m3]
Format=%H:%M:%S

[mt1]
Meter=String
DynamicVariables=1
Text=[m5]
FontColor=255,255,255
User avatar
Halloyo
Posts: 31
Joined: June 17th, 2020, 3:08 am

Re: Looping countdown to specific hour

Post by Halloyo »

Thank you! It works perfectly! (But, TimeStampFormat isn't required and it actually returned an error for me)

EDIT: Wait, no, nevermind. I thought it worked ahh... it returned the current date. I'll look into it. Oops
User avatar
Halloyo
Posts: 31
Joined: June 17th, 2020, 3:08 am

Re: Looping countdown to specific hour

Post by Halloyo »

I know I shouldn't double-post, but I managed to make it work:

Thank you Pflosch, for showing me the way :D (The thing with your approach was that it wouldn't work past 23pm. Also, I was looking for a countdown to 11 am, but it's ok)

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=255,255,255

[Variables]
date=TomorrowFormatted

[Countdown]
Meter=String
DynamicVariables=1
Text="[#date#]"
FontSize=24
Antialias=1
FontColor=255,0,0

[Countdown2]
Measure=Time
Format=%H%M%S
IfCondition=Countdown2<=110000
IfTrueAction=[!WriteKeyValue variables date "TodayFormatted"][!UpdateMeter Countdown][!Redraw]
IfFalseAction=[!WriteKeyValue variables date "TomorrowFormatted"][!UpdateMeter Countdown][!Redraw]

[TestText]
Meter=String
DynamicVariables=1
Text=[TodayFormatted]
FontSize=24
Antialias=1
Y=50

[Today]
Measure=Time

[TodayDate]
Measure=Time
Format=%Y-%m-%d

[Tomorrow]
Measure=Time
TimeStamp=([Today:]+86400)
Format=%Y-%m-%d
DynamicVariables=1

[Tomorrow2]
Measure=Time
DynamicVariables=1
Timestamp=[Tomorrow]
TimestampFormat=%Y-%m-%d
Format=%F

[Tomorrow3]
Measure=Calc
DynamicVariables=1
Formula=[Tomorrow2:timestamp]-[Today:]+39600
;39600 = (11h*3600secs)

[TomorrowFormatted]
Measure=Time
DynamicVariables=1
Timestamp=[Tomorrow3]
Format=%H:%M:%S

[Today11am]
Measure=Time
Timestamp=[TodayDate] 11:00:00
TimestampFormat=%Y-%m-%d %H:%M:%S

[Today1]
Measure=Calc
DynamicVariables=1
Formula=[Today11am:timestamp]-[Today:]

[TodayFormatted]
Measure=Time
DynamicVariables=1
Timestamp=[Today1]
Format=%H:%M:%S
Pflosch
Posts: 27
Joined: May 24th, 2020, 7:04 am

Re: Looping countdown to specific hour

Post by Pflosch »

Sorry, was a quick shot, yes I forgot to add a day, if after reset time.
That's why it returned actual time once reset time is over on this day.

As for the TimestampFormat, I'm kinda puzzled, If I remove it, it doesn't work for me anymore.

Anyway, glad you solved it.
User avatar
Halloyo
Posts: 31
Joined: June 17th, 2020, 3:08 am

Re: Looping countdown to specific hour

Post by Halloyo »

That was me jumping the gun. I saw the original code returned an error, I removed TimeStampFormat and there were no errors. I thought that I had solved it, but I didn't realize at the time that the timer wasn't working like it should've.
User avatar
balala
Rainmeter Sage
Posts: 11369
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Looping countdown to specific hour

Post by balala »

Halloyo wrote: June 28th, 2020, 9:29 pm I know I shouldn't double-post, but I managed to make it work:

Thank you Pflosch, for showing me the way :D (The thing with your approach was that it wouldn't work past 23pm. Also, I was looking for a countdown to 11 am, but it's ok)

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=255,255,255

[Variables]
date=TomorrowFormatted

[Countdown]
Meter=String
DynamicVariables=1
Text="[#date#]"
FontSize=24
Antialias=1
FontColor=255,0,0

[Countdown2]
Measure=Time
Format=%H%M%S
IfCondition=Countdown2<=110000
IfTrueAction=[!WriteKeyValue variables date "TodayFormatted"][!UpdateMeter Countdown][!Redraw]
IfFalseAction=[!WriteKeyValue variables date "TomorrowFormatted"][!UpdateMeter Countdown][!Redraw]

[TestText]
Meter=String
DynamicVariables=1
Text=[TodayFormatted]
FontSize=24
Antialias=1
Y=50

[Today]
Measure=Time

[TodayDate]
Measure=Time
Format=%Y-%m-%d

[Tomorrow]
Measure=Time
TimeStamp=([Today:]+86400)
Format=%Y-%m-%d
DynamicVariables=1

[Tomorrow2]
Measure=Time
DynamicVariables=1
Timestamp=[Tomorrow]
TimestampFormat=%Y-%m-%d
Format=%F

[Tomorrow3]
Measure=Calc
DynamicVariables=1
Formula=[Tomorrow2:timestamp]-[Today:]+39600
;39600 = (11h*3600secs)

[TomorrowFormatted]
Measure=Time
DynamicVariables=1
Timestamp=[Tomorrow3]
Format=%H:%M:%S

[Today11am]
Measure=Time
Timestamp=[TodayDate] 11:00:00
TimestampFormat=%Y-%m-%d %H:%M:%S

[Today1]
Measure=Calc
DynamicVariables=1
Formula=[Today11am:timestamp]-[Today:]

[TodayFormatted]
Measure=Time
DynamicVariables=1
Timestamp=[Today1]
Format=%H:%M:%S
I can't entirely follow what's going on here, but in meantime I also wrote a small code and even if you got the skin working as intended, I'm gonna post mine as well.
In my code there is a CountTo variable ([Variables] section), which stores the time to count down to. It is set now to CountTo=11:00, which means the skin will count down to 11:00 AM (the variable is expressed into 24 hour format, not 12!) and then it restarts until next 11:00AM and so on.
You can simply change the moment to count down to, changing this variable.

Code: Select all

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

[Variables]
CountTo=11:00

[MeasureDate]
Measure=Time
Format=%Y-%m-%d

[MeasureTomorrow]
Measure=Time
Format=%Y-%m-%d
TimeStamp=([MeasureDate:TimeStamp]+86400)
DynamicVariables=1

[MeasureCountTo]
Measure=Time
Format=%Y-%m-%d %H:%M:%S
TimeStamp=[MeasureDate] #CountTo#
TimeStampFormat=%Y-%m-%d %H:%M
DynamicVariables=1

[MeasureCountTomorrow]
Measure=Time
Format=%Y-%m-%d %H:%M:%S
TimeStamp=[MeasureTomorrow] #CountTo#
TimeStampFormat=%Y-%m-%d %H:%M
DynamicVariables=1

[MeasureRemains]
Measure=Calc
Formula=((( [MeasureDate:TimeStamp] > [MeasureCountTo:TimeStamp] ) ? [MeasureCountTomorrow:TimeStamp] : [MeasureCountTo:TimeStamp] ) - [MeasureDate:TimeStamp] )
DynamicVariables=1

[MeasureRemainsTime]
Measure=Uptime
SecondsValue=[MeasureRemains]
Format=%3!02i!:%2!02i!:%1!02i!
DynamicVariables=1

[MeterCountDown]
Meter=STRING
MeasureName=MeasureRemainsTime
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=%1 until #CountTo#
The essence of this code is the CountTo variable. Please let me know if you have any question.
User avatar
Mor3bane
Posts: 944
Joined: May 7th, 2016, 7:32 am

Re: Looping countdown to specific hour

Post by Mor3bane »

******DISREGARD******ALTERNATE OPTION FOUND******

Hi, this caught my eye and I feel I can make use of this count down idea.

In this code below, is it possible to include the year, month, day, hour minute, and seconds by simply modifying the few lines?

Code: Select all

[Variables]
CountTo=11:00

[MeasureDate]
Measure=Time
Format=%Y-%m-%d

[MeasureTomorrow]
Measure=Time
Format=%Y-%m-%d
TimeStamp=([MeasureDate:TimeStamp]+86400)
DynamicVariables=1

[MeasureCountTo]
Measure=Time
Format=%Y-%m-%d %H:%M:%S
TimeStamp=[MeasureDate] #CountTo#
TimeStampFormat=%Y-%m-%d %H:%M
DynamicVariables=1

[MeasureCountTomorrow]
Measure=Time
Format=%Y-%m-%d %H:%M:%S
TimeStamp=[MeasureTomorrow] #CountTo#
TimeStampFormat=%Y-%m-%d %H:%M
DynamicVariables=1
To something like this?

Code: Select all

[Variables]
CountTo=2020:09:05:11:00:00

[MeasureDate]
Measure=Time
Format=%Y:%m:%d

[MeasureTomorrow]
Measure=Time
Format=%Y:%m:%d
TimeStamp=([MeasureDate:TimeStamp]+86400)
DynamicVariables=1

[MeasureCountTo]
Measure=Time
Format=%Y:%m:%d:%H:%M:%S
TimeStamp=[MeasureDate] #CountTo#
TimeStampFormat=%Y:%m:%d:%H:%M
DynamicVariables=1

[MeasureCountTomorrow]
Measure=Time
Format=%Y:%m:%d:%H:%M:%S
TimeStamp=[MeasureTomorrow] #CountTo#
TimeStampFormat=%Y:%m:%d:%H:%M
DynamicVariables=1
To ease eyestrain, I simply added in ":" this character where there were "-" or a space " ".

I was afraid to test it - not sure why. So I asked before trying this modifications.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
balala
Rainmeter Sage
Posts: 11369
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Looping countdown to specific hour

Post by balala »

Mor3bane wrote: July 8th, 2020, 2:41 am In this code below, is it possible to include the year, month, day, hour minute, and seconds by simply modifying the few lines?
Include where? Year, month and day is already included, so where would you like to add them once more? Or would you like one single countdown to a specified moment (date and time)? If you would, this means one single countdown, not a loop, which although is possible, is not what this topic has been started for.
So details please, on what you're looking for.
Mor3bane wrote: July 8th, 2020, 2:41 am I was afraid to test it - not sure why. So I asked before trying this modifications.
Why? It never hurts. Just test everything you're writing, there is no other possibility. In worst case, it doesn't work, but can't get any worse.