Page 1 of 1

Measure Time %a to Number

Posted: October 31st, 2018, 9:10 pm
by Goonomi
Hi y'all,

i'm working on a little calendar and i found something that is driving me crazy:

Code: Select all

[Rainmeter]
Author=Goonomi

[MeasureDayOfWeek]
Measure=Time
Format=%a

[MeasureDayOfWeekNumber]
Measure=Calc
Formula=MeasureDayOfWeek="Mon" ? 0 :
        MeasureDayOfWeek="Tue" ? 1 :
        MeasureDayOfWeek="Wed" ? 2 : 
        MeasureDayOfWeek="Thu" ? 3 :
        MeasureDayOfWeek="Fri" ? 4 :
        MeasureDayOfWeek="Sat" ? 5 : 
        MeasureDayOfWeek="Sun" ? 6 :
        -1

[MeasureNextDayOfWeek]
Measure=Calc
Formula=MeasureDayOfWeekNumber+1

[MeterConsole2]
Meter=String
AntiAlias=1
Checking this .ini on the Protocoll gives me this: (i attached the picture, no idea how to link it into this text ...)
The [MeasureDayOfWeek] returns Wed but [MeasureDayOfWeekNumber] checks for "Wed" (for today) and doesnt find it.

Any help would be greatly appreciated

Re: Measure Time %a to Number

Posted: October 31st, 2018, 9:29 pm
by balala
The Formula option of a Calc measure must be entirely numeric. String are not allowed. For such action, you have to use IfMatch options.
However in this case nor this is needed, because the Format option of Time measure has two values which return the weekday as number:
•%u: ISO 8601 weekday as number with Monday as first day of week. (1 - 7)
...
•%w: Weekday as number with Sunday as first day of week. (0 - 6)
So, if you replace the Format=%a option of the [MeasureDayOfWeek] measure with Format=%u, you'll get a number between 1 (for Monday) and 7 (for Sunday). If needed a Calc measure can be used to extract one from the above value, to get it as you need it:

Code: Select all

[MeasureDayOfWeekNumber]
Measure=Calc
Formula=( MeasureDayOfWeek - 1 )

Re: Measure Time %a to Number

Posted: November 1st, 2018, 9:15 am
by Goonomi
So, if you replace the Format=%a option of the [MeasureDayOfWeek] measure with Format=%u, you'll get a number between 1 (for Monday) and 7 (for Sunday).
Oh, wow. So simple. Thanks a ton balala.

Re: Measure Time %a to Number

Posted: November 1st, 2018, 12:29 pm
by balala
You're welcome.