problem with a <label>
#1
Trying to create a <label> in a skin that will return the days of the week in an abbreviated form. ie: Mon, Tue, Wed, etc.

I was thinking using System.Date(ddd) would work.

But how would I go about adding to it so the days of the week populate?

I need it to go like this: if today is Fri and the above returns that, how would I code it so that in another <label> I can essentially add 1 so it returns Sat? Add 2 so it returns Sun, etc.

And, no, static labels will not work.
Reply
#2
I'd use variables.

eg Variables.xml -

PHP Code:
<?xml version="1.0" encoding="UTF-8"?>
<includes>

    <variable name="Day_Plus_1">
        <value condition="StringCompare(System.Date(ddd),$LOCALIZE[41])">$LOCALIZE[42]</value>
        <value condition="StringCompare(System.Date(ddd),$LOCALIZE[42])">$LOCALIZE[43]</value>
        <value condition="StringCompare(System.Date(ddd),$LOCALIZE[43])">$LOCALIZE[44]</value>
        <value condition="StringCompare(System.Date(ddd),$LOCALIZE[44])">$LOCALIZE[45]</value>
        <value condition="StringCompare(System.Date(ddd),$LOCALIZE[45])">$LOCALIZE[46]</value>
        <value condition="StringCompare(System.Date(ddd),$LOCALIZE[46])">$LOCALIZE[47]</value>
        <value condition="StringCompare(System.Date(ddd),$LOCALIZE[47])">$LOCALIZE[41]</value>
    </variable>

</includes> 

Then -

PHP Code:
<label>$VAR[Day_Plus_1]</label

Just repeat the code for the other days but bump the last $LOCALIZE[nn] to suit.

EDIT: $LOCALIZE[41] = Mon / $LOCALIZE[47] = Sun
Reply
#3
That would appear to work but looks to be a very long work around for what I'm trying to achieve.

Is there not anyway to truncate a string to a specified length?

For example:
<label>$INFO[Window.Property(Day1.Title)]</label>
Result: Wednesday
Result I'm trying to achieve: Wed

I just want to abbreviate the full string of the day of the week to 3 characters.
Reply
#4
I thought you wanted the current day followed by the next, then the next, etc in some sort of calendar form.

Just use <label>$INFO[System.Date(ddd)]</label>.
Reply
#5
My apologies for not being entirely clear.
This is going into the weather page so I do need all the days of the week [in 3 char abbreviated format].
But I need it based off of this variable Window.Property(Day1.Title).

<label>$INFO[Window.Property(Day1.Title)]</label> returns SAT
<label>$INFO[Window.Property(Day2.Title)]</label> returns SUN
<label>$INFO[Window.Property(Day3.Title)]</label> returns MON
etc...
Reply
#6
PHP Code:
<variable name="Short_Day">
    <
value condition="StringCompare(Window(Weather).Property(Day0.Title),$LOCALIZE[11])">$LOCALIZE[41]</value>
    <
value condition="StringCompare(Window(Weather).Property(Day1.Title),$LOCALIZE[12])">$LOCALIZE[42]</value>
    <
value condition="StringCompare(Window(Weather).Property(Day2.Title),$LOCALIZE[13])">$LOCALIZE[43]</value>
    <
value condition="StringCompare(Window(Weather).Property(Day3.Title),$LOCALIZE[14])">$LOCALIZE[44]</value>
    <
value condition="StringCompare(Window(Weather).Property(Day4.Title),$LOCALIZE[15])">$LOCALIZE[45]</value>
    <
value condition="StringCompare(Window(Weather).Property(Day5.Title),$LOCALIZE[16])">$LOCALIZE[46]</value>
    <
value condition="StringCompare(Window(Weather).Property(Day6.Title),$LOCALIZE[17])">$LOCALIZE[47]</value>
</
variable

PHP Code:
<label>$VAR[Short_Day]</label
Reply

Logout Mark Read Team Forum Stats Members Help
problem with a <label>0