It is currently April 28th, 2024, 4:13 am

'Days until' countdown will not update

Get help with creating, editing & fixing problems with skins
Unjustified
Posts: 6
Joined: August 4th, 2012, 10:26 pm

'Days until' countdown will not update

Post by Unjustified »

So I've been messing around with a little skin to count down the days until Halloween, Christmas, New Year etc.... It all works perfectly until the next day where I have to manually refresh the skin. Im not sure why the skin wont refresh automatically, if anyone has any ideas?

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=1

[Metadata]
Name=Days
Author=Me
Information=Countdown days
Version=1.0

;=============================================================

[TextStyle]
FontColor=145,20,20,255
FontFace=Segoe Print
FontSize=14
StringAlign=Left
AntiAlias=1
stringStyle=Bold

;=============================================================

[ThisYear]
Measure=Time
Format=%Y

[Variables]

NewYearsDay=01/01/[ThisYear]
EasterSunday=27/03/[ThisYear]
MayBankHoliday=02/05/[ThisYear]
SpringBankHoliday=30/05/[ThisYear]
SummerBankHoliday=29/08/[ThisYear]
Halloween=31/10/[ThisYear]
Bonfire=05/11/[ThisYear]
Christmas=25/12/[ThisYear]
NewYearsEve=31/12/[ThisYear]

;=============================================================

[measureToday]
Measure=Time
Format=%d/%m/%Y

[measureNewYear]
Measure=Time
TimeStamp=#NewYearsDay#
TimeStampFormat=%d/%m/%Y

[measureCalcNewYear]
measure=Calc
formula=(([measureNewYear:TimeStamp] - [measureToday:TimeStamp]) / 86400)
IfBelowValue=-1
IfBelowAction=[!HideMeter "meterNewYear"][!Redraw]
IfEqualValue=0
IfEqualAction=[!SetOption "meterNewYear" Text "New Years Day: Today"][!Redraw]

[measureEaster]
Measure=Time
TimeStamp=#EasterSunday#
TimeStampFormat=%d/%m/%Y

[measureCalcEaster]
measure=Calc
formula=(([measureEaster:TimeStamp] - [measureToday:TimeStamp]) / 86400)
IfBelowValue=-1
IfBelowAction=[!HideMeter "meterEasterSunday"][!Redraw]
IfEqualValue=0
IfEqualAction=[!SetOption "meterEasterSunday" Text "Easter Sunday: Today"][!Redraw]

[measureMayBankHoliday]
Measure=Time
TimeStamp=#MayBankHoliday#
TimeStampFormat=%d/%m/%Y

[measureCalcMayBankHoliday]
measure=Calc
formula=(([measureMayBankHoliday:TimeStamp] - [measureToday:TimeStamp]) / 86400)
IfBelowValue=-1
IfBelowAction=[!HideMeter "meterMayBankHoliday"][!Redraw]
IfEqualValue=0
IfEqualAction=[!SetOption "meterMayBankHoliday" Text "May Bank Holiday: Today"][!Redraw]

[measureSpringBankHoliday]
Measure=Time
TimeStamp=#SpringBankHoliday#
TimeStampFormat=%d/%m/%Y

[measureCalcSpringBankHoliday]
measure=Calc
formula=(([measureSpringBankHoliday:TimeStamp] - [measureToday:TimeStamp]) / 86400)
IfBelowValue=-1
IfBelowAction=[!HideMeter "meterSpringBankHoliday"][!Redraw]
IfEqualValue=0
IfEqualAction=[!SetOption "meterSpringBankHoliday" Text "Spring Bank Holiday: Today"][!Redraw]

[measureSummerBankHoliday]
Measure=Time
TimeStamp=#SummerBankHoliday#
TimeStampFormat=%d/%m/%Y

[measureCalcSummerBankHoliday]
measure=Calc
formula=(([measureSummerBankHoliday:TimeStamp] - [measureToday:TimeStamp]) / 86400)
IfBelowValue=-1
IfBelowAction=[!HideMeter "meterSummerBankHoliday"][!Redraw]
IfEqualValue=0
IfEqualAction=[!SetOption "meterSummerBankHoliday" Text "Summer Bank Holiday: Today"][!Redraw]

[measureHalloween]
Measure=Time
TimeStamp=#Halloween#
TimeStampFormat=%d/%m/%Y

[measureCalcHalloween]
measure=Calc
formula=(([measureHalloween:TimeStamp] - [measureToday:TimeStamp]) / 86400)
IfBelowValue=-1
IfBelowAction=[!HideMeter "meterHalloween"][!Redraw]
IfEqualValue=0
IfEqualAction=[!SetOption "meterHalloween" Text "Halloween: Today"][!Redraw]

[measureBonfire]
Measure=Time
TimeStamp=#Bonfire#
TimeStampFormat=%d/%m/%Y

[measureCalcBonfire]
measure=Calc
formula=(([measureBonfire:TimeStamp] - [measureToday:TimeStamp]) / 86400)
IfBelowValue=-1
IfBelowAction=[!HideMeter "meterBonfire"][!Redraw]
IfEqualValue=0
IfEqualAction=[!SetOption "meterBonfire" Text "Bonfire: Today"][!Redraw]

[measureChristmas]
Measure=Time
TimeStamp=#Christmas#
TimeStampFormat=%d/%m/%Y

[measureCalcChristmas]
measure=Calc
formula=(([measureChristmas:TimeStamp] - [measureToday:TimeStamp]) / 86400)
IfBelowValue=-1
IfBelowAction=[!HideMeter "meterChristmas"][!Redraw]
IfEqualValue=0
IfEqualAction=[!SetOption "meterChristmas" Text "Christmas: Today"][!Redraw]

[measureNewYearsEve]
Measure=Time
TimeStamp=#NewYearsEve#
TimeStampFormat=%d/%m/%Y

[measureCalcNewYearsEve]
measure=Calc
formula=(([measureNewYearsEve:TimeStamp] - [measureToday:TimeStamp]) / 86400)
IfBelowValue=-1
IfBelowAction=[!HideMeter "meterNewYearsEve"][!Redraw]
IfEqualValue=0
IfEqualAction=[!SetOption "meterNewYearsEve" Text "New Years Eve: Today"][!Redraw]

;=============================================================

[meterHolder]
Meter=String
X=0
Y=0
W=1
H=1

[meterNewYear]
Meter=String
MeterStyle=TextStyle
MeasureName=measureCalcNewYear
X=0
Y=0R
W=300
H=30
Text=New Years Day: %1

[meterEasterSunday]
Meter=String
MeterStyle=TextStyle
MeasureName=measureCalcEaster
X=0
Y=0R
W=300
H=30
Text=Easter Sunday: %1

[meterMayBankHoliday]
Meter=String
MeterStyle=TextStyle
MeasureName=measureCalcMayBankHoliday
X=0
Y=0R
W=300
H=30
Text=May Bank Holiday: %1

[meterSpringBankHoliday]
Meter=String
MeterStyle=TextStyle
MeasureName=measureCalcSpringBankHoliday
X=0
Y=0R
W=300
H=30
Text=Spring Bank Holiday: %1

[meterSummerBankHoliday]
Meter=String
MeterStyle=TextStyle
MeasureName=measureCalcSummerBankHoliday
X=0
Y=0R
W=300
H=30
Text=Summer Bank Holiday: %1

[meterHalloween]
Meter=String
MeterStyle=TextStyle
MeasureName=measureCalcHalloween
X=0
Y=0R
W=300
H=30
Text=Halloween: %1

[meterBonfire]
Meter=String
MeterStyle=TextStyle
MeasureName=measureCalcBonfire
X=0
Y=0R
W=300
H=30
Text=Bonfire Night: %1

[meterChristmas]
Meter=String
MeterStyle=TextStyle
MeasureName=measureCalcChristmas
X=0
Y=0R
W=300
H=30
Text=Christmas: %1

[meterNewYearsEve]
Meter=String
MeterStyle=TextStyle
MeasureName=measureCalcNewYearsEve
X=0
Y=0R
W=300
H=30
Text=New Years Eve: %1
Thanks in advance!
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: 'Days until' countdown will not update

Post by Mordasius »

One way you can automatically refresh the skin when the date changes is to add OnChangeAction to [measureToday]

Code: Select all

[measureToday]
Measure=Time
Format=%d/%m/%Y
OnChangeAction=[!Refresh]
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: 'Days until' countdown will not update

Post by jsmorley »

You should not have to refresh the skin.

The problem is that you need to use DynamicVariables=1 on any measure or meter that is using a [SectionVariable] like:

formula=(([measureNewYear:TimeStamp] - [measureToday:TimeStamp]) / 86400)

[measureCalcNewYear]
measure=Calc
formula=(([measureNewYear:TimeStamp] - [measureToday:TimeStamp]) / 86400)
IfBelowValue=-1
IfBelowAction=[!HideMeter "meterNewYear"][!Redraw]
IfEqualValue=0
IfEqualAction=[!SetOption "meterNewYear" Text "New Years Day: Today"][!Redraw]
DynamicVariables=1

If you don't, then those measures will have their initial value, but will never update.

The fact that really none of your measures are working is sorta hidden by the fact that whatever "today" is when the skin is refreshed is still valid as long as it is still "today", but as soon as the day changes, those timestamps that are stuck on the time the skin was loaded or refreshed are now "yesterday"...

This will include any measures that are "indirectly" using a [SectionVariable] like:

[measureNewYear]
Measure=Time
TimeStamp=#NewYearsDay#
TimeStampFormat=%d/%m/%Y
DynamicVariables=1

Since there is a section variable [Year] embedded in that #NewYearsDay# variable. If you don't then it will be fine as long as it is still 2015, but when it changes to 2016 it won't update to reflect that without a refresh.
msllol
Posts: 3
Joined: October 5th, 2015, 10:24 pm

Re: 'Days until' countdown will not update

Post by msllol »

does this calculates leap years too.like 2016?
Unjustified
Posts: 6
Joined: August 4th, 2012, 10:26 pm

Re: 'Days until' countdown will not update

Post by Unjustified »

Thank you both mordasius and jsmorley... Have implemented changes and will see if it automatically changes at midnight in 3 hours.
msllol wrote:does this calculates leap years too.like 2016?
Yes it does include leap years. Using http://days.to/ to check the days until, and unhiding some of the meters, they all seem to add up correctly.

Next step will be some complicated math to work out when bank holidays are, instead of relying on changing the dates manually at the beginning of each year.