Dear community,
I try to show some dates in an oh3-widget by parsing a string with the dayjs-integration. But I can’t get it to work to show the right date-time.
My String Item stores following example string (length varies, structure always the same, splitting by ‘_’):
2021-05-12T20:00+02:00[Europe/Berlin]_2021-05-15T20:00+02:00[Europe/Berlin]
In the oh3-widget I created an oh-repeater component which iterates over an array, which I create by items[loop.dayString].state.split('_')
.
When I leave the `[Europe/Berlin]’ part in the String, the dayJS can’t create a proper date-time representation.
If I remove the `[Europe/Berlin]’ part in the String, the dayJS creates a proper date-time representation, but in the wrong TimeZone (GMT). My host system is running in TimeZone UTC+2 and the Docker-Container (witch serves openHAB) gets the TimeZone from the host system. I checked in the Docker-Container - TimeZone is CEST. So the timezones are the same…
Summarize
- Given String:
2021-05-12T20:00+02:00[Europe/Berlin]
- Inject into dayJS in oh3-widget: not possible to create date-time representation
- Remove content between
[]
==>2021-05-12T20:00+02:00
- Inject into dayJS in oh3-widget: wrong TimeZone representation (it gets GMT)
- Host system and Docker-Container have CEST (UTC+2)
Problem
- How to properly parse ZonedDateTime.toString with dayJS to get proper DateTime representation in oh3-widget