It is currently April 27th, 2024, 7:57 pm

Problem with Time-%w - Weekday as decimal number

Get help with creating, editing & fixing problems with skins
Fried_Ice
Posts: 6
Joined: December 16th, 2011, 6:50 pm
Location: Germany

Problem with Time-%w - Weekday as decimal number

Post by Fried_Ice »

Hi Guys,
At the moment I am workin on a skin which displays the current time.
To support the simple String of the different values I decided to put the Strings inside a BarMeter showing the progress of the hours, seconds and so on.
All works fine but the Weekdays.
I used the Measure "%w - Weekday as decimal number (0 - 6; Sunday is 0)" to get the current Day. But I am interesting in having the Monday as the first day of the week so I tried to solve the peoblem like this:

Code: Select all

[MeasureDayValue]
Measure=Time
Format=%w
Substitute=Substitute="0":"6","1":"2","2","3","3":"4","4":"5","5":"6","6":"0"
MinValue=0
MaxValue=6
The result: nothing changed... :(
Could anyone help me finding another way to convert these values?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Problem with Time-%w - Weekday as decimal number

Post by jsmorley »

Code: Select all

[MeasureDayValue]
Measure=Time
Format=-%w
Substitute="-0":"6","-1":"0","-2":"1","-3":"2","-4":"3","-5":"4","-6":"5"

[MeasureValueForBar]
Measure=Calc
Formula=[MeasureDayValue]
MinValue=0
MaxValue=6
DynamicVariables=1

[MeterOne]
Meter=Bar
MeasureName=MeasureValueForBar
W=100
H=20
BarColor=255,255,255,255
SolidColor=105,37,6,150
BarOrientation=HORIZONTAL
First, you have Substitute= twice on the measure and a small typo with "," instead of ":" in one spot. Second, I added a "-" to the format statement, so I can then properly do the Substitute without having the fact that they are done one after another cause part two just overwrite part one. Then, I used a Calc measure to set the MinValue and MaxValue, as they are only valid on measures that return numbers, and the Time measure returns a string.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Problem with Time-%w - Weekday as decimal number

Post by smurfier »

I recommend a slightly different approach.

Code: Select all

[MeasureDayValue]
Measure=Time
Format=%w

[MeasureValueForBar]
Measure=Calc
Formula=[MeasureDayValue]=0?6:[MeasureDayValue]-1
MinValue=0
MaxValue=6
DynamicVariables=1

[MeterOne]
Meter=Bar
MeasureName=MeasureValueForBar
W=100
H=20
BarColor=255,255,255,255
SolidColor=105,37,6,150
BarOrientation=HORIZONTAL
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Problem with Time-%w - Weekday as decimal number

Post by jsmorley »

Yep, either will work.
Fried_Ice
Posts: 6
Joined: December 16th, 2011, 6:50 pm
Location: Germany

Re: Problem with Time-%w - Weekday as decimal number

Post by Fried_Ice »

Works Perfect-Thanks alot ;D

Now I got the next problem^^
When I draw the bars of days, the masure must have a MaxValue which depends of the number of days the month has.
How could I implement that?
Last edited by Fried_Ice on December 16th, 2011, 8:09 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Problem with Time-%w - Weekday as decimal number

Post by jsmorley »

Glad to help.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Problem with Time-%w - Weekday as decimal number

Post by smurfier »

Code: Select all

[msYear]
Measure=Time
Format=%#Y

;Gotta test for a leap year
[cFeb]
Measure=Calc
Formula=28+((msYear%4)=0)

[msMonth]
Measure=Time
Format=%#m

[cMonthDays]
Measure=Calc
Formula=-msMonth
Subsitute="-1":"31","-2":"[cFeb]","-3":"31","-4":"30","-5":"31","-6":"30","-7":"31","-8":"31","-9":"30","-10":"31","-11":"30","-12":"31"
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .