-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Provide time.toInstant
method
#413
Conversation
d93cb68
to
d02bb08
Compare
@florian-h05 - what is your opinion here? I think the conversions from Java and openHAB types (like native Date, Java |
The conversion from from Java and openHAB types clearly is a must-have, and I would also opt to add the |
Okay, let's leave that then. So you'd be okay with removing |
Yes, those conversions always seemed weird, but keep in mind that this is still a breaking change. |
I would only remove them from the new |
Okay in that case, no problem 👍 |
Resolves openhab#412 Signed-off-by: Jacob Laursen <[email protected]>
d02bb08
to
9a4476d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from two documentation comments, looks good to me!
Signed-off-by: Jacob Laursen <[email protected]>
28b8784
to
024b6ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
One minor typo left. Please refrain from further force pushes.
Signed-off-by: Jacob Laursen <[email protected]>
This provides a convenience method for constructing a
time.toInstant
from various input types, similar totime.toZDT
.The main purpose and motivation is to simplify this:
to the more straight-forward (and faster):
Please note I have deliberately left out a few conversions provided by
time.toZDT
which I consider slightly misleading and/or bloated, for example considering a number to be a number of milliseconds to be added tonow
. This can be achieved by directly using the js-joda classes, e.g.time.Instant.now().plusMillis(500)
which to me seems more readable thantime.toInstant(500)
.I was in doubt whether to even add
time.toInstant()
(without parameter) in favor of usingtime.Instant.now()
, but it seems so commonly used fortime.toZDT
that I decided to leave it in for first review iteration to be discussed. I also provided those operations working directly on items, although I also have doubts aboutDecimalType
andQuantityType
.Testing
Output:
Resolves #412