Hi there. I'm trying to display a perpetual countdown timer to my fixed pay day each month. My pay day is stored in a variable (#payDate#). To determine my next pay day, firstly I calculate whether it's this month or next month (see [measureNextPayMonth]) by simply comparing the day of today's date with pay day. If today's date is >= pay day, my next pay day is next month otherwise it's this month. This measure is currently evaluating to 08 which is correct because my next pay day is indeed in August (the substitution btw is just to pad single digits with a zero).
Unfortunately when I try to feed [measureNextPayMonth] into the timestamp expression in [measureNextPayDay], it evaluates a date way, way in the past (13222915200). If I put in the actual correct number (08) instead of [measureNextPayMonth], however, [measureNextPayDay] and hence [measureCountdown] both evaluate exactly as I want. Any advice either about where I'm going wrong or even an easier way to do it would be most welcome. I should add I'm not new to Rainmeter but I haven't used it for about 10 years so I'm more than a bit rusty. Also I know [measureYear] needs some work to make it work going forward but I want to sort this problem first if possible.
Endemoniada wrote: ↑July 26th, 2020, 7:02 pm
Hi there. I'm trying to display a perpetual countdown timer to my fixed pay day each month. My pay day is stored in a variable (#payDate#). To determine my next pay day, firstly I calculate whether it's this month or next month (see [measureNextPayMonth]) by simply comparing the day of today's date with pay day. If today's date is >= pay day, my next pay day is next month otherwise it's this month. This measure is currently evaluating to 08 which is correct because my next pay day is indeed in August (the substitution btw is just to pad single digits with a zero).
Unfortunately when I try to feed [measureNextPayMonth] into the timestamp expression in [measureNextPayDay], it evaluates a date way, way in the past (13222915200). If I put in the actual correct number (08) instead of [measureNextPayMonth], however, [measureNextPayDay] and hence [measureCountdown] both evaluate exactly as I want. Any advice either about where I'm going wrong or even an easier way to do it would be most welcome. I should add I'm not new to Rainmeter but I haven't used it for about 10 years so I'm more than a bit rusty. Also I know [measureYear] needs some work to make it work going forward but I want to sort this problem first if possible.
There are more problems with your code. The most important is that you have to add a DynamicVariables=1 option to the [measureNextPayDay] measure, because it uses section variables ([measureNextPayMonth] and [measureYear]) and these are requiring to set on the dynamic variables.
On the other hand I also would replace the Formula option of the [measureCountdown] measure with the following one: Formula=( [measureNextPayDay:TimeStamp] - [measureNow:TimeStamp] ). See that in this formula I extracted the time stamp of the [measureNow] measure, from the time stamp of the [measureNextPayDay] measure. Both being time measures, extracting them from each other can cause a lot of problems. Additionally [measureNextPayDay:TimeStamp] and [measureNow:TimeStamp] are again section variables, so you have to add the DynamicVariables=1 option to this measure as well.
However you'll get an error on December, when after 08, [measureNextPayMonth] will return 13 and as we all know, such a month doesn't exist.
balala wrote: ↑July 26th, 2020, 7:49 pm
There are more problems with your code. The most important is that you have to add a DynamicVariables=1 option to the [measureNextPayDay] measure, because it uses section variables ([measureNextPayMonth] and [measureYear]) and these are requiring to set on the dynamic variables.
On the other hand I also would replace the Formula option of the [measureCountdown] measure with the following one: Formula=( [measureNextPayDay:TimeStamp] - [measureNow:TimeStamp] ). See that in this formula I extracted the time stamp of the [measureNow] measure, from the time stamp of the [measureNextPayDay] measure. Both being time measures, extracting them from each other can cause a lot of problems. Additionally [measureNextPayDay:TimeStamp] and [measureNow:TimeStamp] are again section variables, so you have to add the DynamicVariables=1 option to this measure as well.
However you'll get an error on December, when after 08, [measureNextPayMonth] will return 13 and as we all know, such a month doesn't exist.
That's very helpful indeed, thanks. My initial thoughts on how to cope with December and the year change: add a mod 12 function to the formula for [measureNextPayMonth] so that it evaluates to 1 not 13 after pay day in December; create a new calculated measure [measureNextPayYear] to use in [measureNextPayDay] which returns the current year + 1 if the month is December.
Endemoniada wrote: ↑July 26th, 2020, 8:39 pm
My initial thoughts on how to cope with December and the year change: add a mod 12 function to the formula for [measureNextPayMonth] so that it evaluates to 1 not 13 after pay day in December; create a new calculated measure [measureNextPayYear] to use in [measureNextPayDay] which returns the current year + 1 if the month is December.
Endemoniada wrote: ↑July 26th, 2020, 8:56 pm
I think it will if I add:
Substitute="0":"12"
to [measureNextPayMonth].
Right. I probably would suggest to add the new substitution before the existing one and add the appropriate ^ and $ characters as well: Substitute="^0$":"12","^(\d)$":"0\0".
balala wrote: ↑July 27th, 2020, 6:52 am
Right. I probably would suggest to add the new substitution before the existing one and add the appropriate ^ and $ characters as well: Substitute="^0$":"12","^(\d)$":"0\0".