Format date

Dear all, I am using Keba-binding and this is working fine for me.

I have a question related to the uptime:

DateTime KebaUptime         "Zeit Online [%1$tY Y, %1$tm M, %1$td D,  %1$tT]"                   <time>      (gWallbox)          {channel="keba:kecontact:0f834fe37:uptime"}

The result looks like this:


If I change the format to a string the results looks like this:


Unfortunately the results are not really human readable.

Any chance or ideas how to read or better to change the format?

That’s not so helpful for an elapsed time.
What would you like the results to look like?

I would expect something like:
Uptime since : 1 year, 3 month, 2 days 4 hours, 10 minutes

Okay, because your elapsed time comes in a datetime format it is not straightforward.

If you didn’t expect uptime measured in years, you could cheat a bit by assuming calendar dates to be the same as elapsed time (so long as you don’t mind 0 being displayed)
[%1$tm month, %1$td days, %1$tH hours, %1$tm minutes]

As an aside, if you’re expecting uptime in years, why worry about the minutes?

If you want something neater, I think you’ll have to write a JS transform so that you can do the necessary like subtract 1972 from the year.

Thanks. This works in general fine.
I assume the leading zero and the words (singular / plural) could be handled better with a JS transform?
Do you have a proposal for JS transform as well?

Yes indeed, and you can make it show stuff like “50 days”, or drop minutes once you get to months elapsed, etc.
You might base something off of this

You’d need to express your datetime as an “epoch” time, which would give you elapsed time since 1972 as a number. Then you can divide as you wish for years, minutes, etc.

It would be a useful enhancement if the binding supplied the uptime as a Number:Time channel instead of dateTime. I expect that wasn’t available when it was written.