Duration channel formatting in GUI

I feel a complete dumb*** but somehow i cannot get something simple to work.

This Number:Duration channel has been linked to an item by the GUI, it’s value is 1.529204923659563 day. I want to show it as 1 day, 11 hours 39 minute or similar.
When i add the metadata widget digital clock card, it shows the time without the day. So i alter the Timeformat to {DD HH:mm:ss} now it shows 24 11:40:34 (the date and time of today, not from the item duration) The format is right, but it seems not to be related to the item value.

I searched the forum and the documention pages, but i can not find a clear answer on how to set this up by the gui.

Clock time is not duration. Foi example, the first day of the year is “1”, when duration of the year is still “0” days + x hours etc.

There are a number of transformations in this forum - my own example

Thanks for pointing me in the right direction.
This is the part where i hate openHAB. it is so versatile that it overcomplicates something simple as showing a duration. When looking for a solution i get stuck between all kind of concepts and technical lingo. And i don’t classify myself as a beginner. I don’t understand why there is no default widget for duration as uptime, timers, seen x minutes ago etc. There are so many use cases. I’m no UI developer myself, otherwise i would have created one.

Sorry, just have some need to express my frustration :slight_smile:

To the topic:
So i added the js file to the transform folder, changed the widget to oh-label-card. But now i cannot find the syntax to add this transformation to the main ui label.
I removed the current metadata and replaced it with a state description metadata (wahtever that may be :-/) Added the pattern and had no result. This is the definition:

value: " "
  pattern: duration [JS(clockfmt.js):%s]

Sowing a duration is simple, 1.5 days. Your requirement adds the complication.

JS transformation is an installable add-on.

Widgets can select to show state (raw) or displayState (transformed and/or formatted)

What requirement is so complicating?
I find displaying a duration in its parts quite common; days hours minutes.

In day to day use we communicate not in 1.67 days, but in days hours minutes. Like Uptime, stopwatches etc. Wasmachines showing time remaining all those need these kind of transformations?! I find it hard to believe that this can’t be simplified.

I have 4.0.0 snapshot and it does not have a js transformation. That may be another piece of the missing puzzle.

Really appreciate your help, don’t get me wrong. At least I now know where to look. Thanks!

That’s another complication I can’t help you with.
This will be because the javascript version available in the underlying Java has been changed. I don’t know what scripted transformations are then available.

You don’t need to be a UI developer, this is only formatting.
Most of the formatting in openHAB is performed by standard Java functions - date/times, decimal places etc. Strangely that doesn’t deal with this common requirement either, nor with formatting lengths as feet and inches, and so on.