Display future date value/item?

This is more of an AngularJS question, but I am trying to do this in HABpanel.

I am working on a custom weather forecast widget for the next 4 days. I would like it to show “today, Wed, Thu, Fri” as headers on the forecast temperatures.

My question is how, can I do some date math to add today + 1, today +2, today + 3 etc.

I can get the value of “today” and translate that to “Wed”, I’m just not sure how I can say now+24 hours for “Thu”

I searched for AngularJS date math, but it all references using other JS libraries.

Any thoughts? Should I put these in an item instead, and let a rule change them each day?

If you are using the weather binding, you can do this fairly easily. Assuming you have ObservationTime0 (for current weather), ObservationTime1 is tomorrow, ObservationTime2 is the next day, etc you can just cast the DateTime to the date command, and format it:

{{itemValue('ObservationTime1') | date:'EEEE'}}

That will print the day of the week only, like “Saturday”. If you want an abbreviated day, like “Sat” I believe you can use ‘EEE’ instead of ‘EEEE’.

Note: This assumes that ObservationTime1 is a DateTime thing in your item file.

1 Like

Thanks, I will have to look at my setup, I only have an ObservationTime, not ObservationTime0, ObservationTime1 etc.

For quick reference, here are typical items for observations for today, tomorrow, and the next day:

// Observation times
DateTime Weather_ObservationTime0  "Observation time [%1$td.%1$tm.%1$tY %1$tH:%1
$tM]"   <text>  {weather="locationId=home, forecast=0, type=condition, property=
observationTime"}
DateTime Weather_ObservationTime1  "Weather Observation time [%1$td.%1$tm.%1$tY
%1$tH:%1$tM]"   {weather="locationId=home, forecast=1, type=condition, property=
observationTime"}
DateTime Weather_ObservationTime2  "Weather Observation time [%1$td.%1$tm.%1$tY
%1$tH:%1$tM]"   {weather="locationId=home, forecast=2, type=condition, property=
observationTime"}

Note the “forecast=1”, “forecast=2”, etc on each line; The forecast= specifies the day… so just add lines like that to your items file for your weather binding and you should have the items you need

Hallo,

My quastion is, how I can change the language for Days in other languages? In the file weather.cfg I have already changed it, but the names of the weekdays are still in English

thanks in advance

Johann