Skip to content
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

Extend support for time.Instant #412

Closed
jlaur opened this issue Dec 28, 2024 · 2 comments · Fixed by #413
Closed

Extend support for time.Instant #412

jlaur opened this issue Dec 28, 2024 · 2 comments · Fixed by #413
Assignees
Labels
enhancement New feature or request

Comments

@jlaur
Copy link
Contributor

jlaur commented Dec 28, 2024

I would like to propose some enhancements for working with time.Instant similar to the functionality provided by time.toZDT.

As an example, I have this rule code:

    var startTime = time.toZDT(lastUpdateItem.state).toInstant();
    var endTime = time.Instant.now();

which I would like to rewrite to something like:

    var startTime = time.toInstant(lastUpdateItem.state);
    var endTime = time.toInstant();

following the conventions of toZDT.

I'm also wondering if it would make sense to even be able to do this to skip parsing strings:

    var startTimeZoned = lastUpdateItem.zonedDateTimeState;
    var startTimeInstant = lastUpdateItem.instantState;

i.e. more "native" support similar to <item>.quantityState and <item>.numericState.

I can volunteer providing the code, but wanted to first discuss the approach and direction.

@jlaur jlaur added the enhancement New feature or request label Dec 28, 2024
@jlaur
Copy link
Contributor Author

jlaur commented Dec 28, 2024

Cc @florian-h05

@florian-h05
Copy link
Contributor

I like the idea of having a time.toInstant function - probably it can share some code with time.toZDT.

I'm also wondering if it would make sense to even be able to do this to skip parsing strings:

You can also do time.toZDT(DateTimeItem) and it will retrieve the ZDT from the Item without parsing strings.

jlaur added a commit to jlaur/openhab-js that referenced this issue Jan 5, 2025
Resolves openhab#412

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-js that referenced this issue Jan 6, 2025
Resolves openhab#412

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-js that referenced this issue Jan 6, 2025
Resolves openhab#412

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-js that referenced this issue Jan 6, 2025
Resolves openhab#412

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
jlaur added a commit to jlaur/openhab-js that referenced this issue Jan 14, 2025
Resolves openhab#412

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants