It is currently March 28th, 2024, 4:11 pm

Measure Time %a to Number

Get help with creating, editing & fixing problems with skins
Post Reply
Goonomi
Posts: 4
Joined: December 9th, 2015, 4:50 pm

Measure Time %a to Number

Post 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
Attachments
why.png
Last edited by Goonomi on November 1st, 2018, 9:16 am, edited 2 times in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Measure Time %a to Number

Post 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 )
Goonomi
Posts: 4
Joined: December 9th, 2015, 4:50 pm

Re: Measure Time %a to Number

Post 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.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Measure Time %a to Number

Post by balala »

You're welcome.
Post Reply