-
-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Number:Time] Error in displaying days in format string #1766
Comments
$tj is for date formatting, day-of-year (first day is 1). I think this is misapplication of java datetime formatter, you have to do your own transformations e.g. from 90 seconds to 1m30s |
I believe Number:Time is based on the OH DateTimeType, which is based on Java's ZonedDateTime. |
A thats an argument that is true, but what is then the use case for Number:Time? |
Formatting
thus the result in the OP is correct. What is missing is a way to print the number of days. In general using Date/Time Formatting here is not the best solution here, I tried to find a way how to format a |
Just an idea. Is ist possible to apply a dynamic format based on the value. 43 Seconds are automaticalls displayed as "43s" Units could be based on selected language. |
Nice idea but I would rather introduce a custom conversion character to represent the "days" value instead of a language dependent formatting. The substitution and the calculation of the value can be done internally. |
Number;Time is exactly intended as duration. It's certainly possible to embed some highly specific duration formatter - I have doubts it would please everybody. "I want to display 5 days 3 hours with no minutes or seconds when it's that long. Or just 45 seconds without 0 days 0 hours 0 minutes when it's that short" Meantime custom display is what transformations are good at. |
Compared to other Quantities time is based on differnent bases unlike other quatities where the base is always a power of 10. With time we have fractione of a secons that is base 10 based, Minutes and Hours that are based on 60 day based on 24 ... So the type should reflekt that. and it should be userfriendly. 2.6 hours is almost useless. |
It's an Item state. It can hold a Quantity Type - this is a single numeric value and a unit. It's of little practical difference to you if it holds 1.5 hours or 90 minutes internally, they're the same duration. What you're on about is presentation. Conversions - no, time duration is not about especially exotic maths. openHAB is quite happy to convert metres to inches (which are not x10), °F to K (which involves an offset as well as factor). There's nothing stopping you requesting an enhancement for Quantity Type in general to allow multi-sectioned quantities, such as "5 feet 3 inches". I can't see much value in that myself. |
Lets say it in a different way. If i have a Number:teperature item, then i expect to format it in °C or °F or what ever in my area is used. If i have a Number:Time than that is a Duration and i expect to format it in an comon way Durations are displayed. I don't care about the stuff behind it in java code. |
Are you confirming you have a presentation issue and you do not care about the internal workings of Number:Time ? Transformations are good for custom presentations. EDIT - I was curious enough to create a demo transformation, described here |
I think we should close this topic. For me is no need to use Number:Time because in my world it brings no benefits above a simple Number. @Rossko57 offers a huge example how to format a Number:Time which could be use for Number as well. Thnaks for that! |
As written in my last comment. Thanks for your efforts. |
Follow up, the biggest benefit I see of the Quantity types is when you get to non-trivial uses, e.g comparing a length from one source "523mm" to another source "0.761 ft", or more like in this case adding "0.76 hours" to "3213.7 s". You don't have to do conversions, it just works. The price would be the added complexity of the trivial stuff ... formatting. Having said that, there isn't much difference between formatting a plain Number and a Number;Time in the style that you wish here. |
This issue has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/number-time-item-in-s-convert-to-hh-mm/130463/2 |
I am on oh3 build #1986. Ihave a Number:time item that gets ist value fromm a mqt channel that represents an uptime. In the state Description i use the following format to display a human readable time value
Thats works well with one exception. As shown in the following picture the item is up for one day an 43 (sorry missed to 42) seconds. Fact is that the uptime at this moment was only 43 seconds. The one day is an error.
The text was updated successfully, but these errors were encountered: