Open
Conversation
Contributor
Author
|
@jlaur FYI |
c8c8283 to
0accbfd
Compare
…hab#3583 By restoring timezone handling, previously deprecated and/or removed method have been restored. The need to provide a timezone every time the date-time should be turned into a string is gone, and logging will again be shown in the correct timezone. Rule DSL is "unbroken" and dealing with DateTimeTypes in scripts simplified. Removed tests have also been restored along with previous test results. Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
8c544e0 to
c16799c
Compare
added 4 commits
February 14, 2026 23:06
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
DateTimeTypes with non-authoritative timezones are converted the the configured timezone (and made authoritative) before being posted on the event bus. Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
…manipulation The following methods have been added: - truncatedTo(TemporalUnit unit) - until(Temporal endExclusive, TemporalUnit unit) - until(DateTimeType endExclusive, TemporalUnit unit) - plus(TemporalAmount amountToAdd) - plus(long amountToAdd, TemporalUnit unit) - minus(TemporalAmount amountToSubtract) - minus(long amountToSubtract, TemporalUnit unit) - isAfter(DateTimeType moment) - isAfter(ChronoZonedDateTime<?> moment) - isAfter(Instant instant) - isBefore(DateTimeType moment) - isBefore(ChronoZonedDateTime<?> moment) - isBefore(Instant instant) Corresponding tests have also been created. Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
c16799c to
4525340
Compare
Contributor
Author
|
Fantastic. The Java25 build fails because they have decided to deprecate 3 letter timezone designations: This is perfectly valid in Java21, and I've used both in tests. Isn't it great how they just love to make life difficult for people by deprecating things that have worked for years. I know that the 3-letter codes has issues, that there are collisions, and that Java used to resolve the ambiguity by looking at the configured locale. It's not "ideal", but it has worked for years and years, and most codes don't collide with anything. It's if some people think that there are too few problems in the world, so they do their best to invent some. I guess I will have to "clean" the tests for 3-letter timezone codes then. |
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is my suggestion to remedy what I described in #5354.
It does not revert the bulk of #3583, it only reverts the erasure of the timezone from
DateTimeType, plus deprecations and other "reductions in functionality" that resulted from it.At the same time, I've tried to address the problem that was the motivation being #3583 as far as I've been able to figure out: The fact that binding authors had to apply the correct timezone when creating timestamps (aka
now()).The way I've addressed that, is that I've introduced a "new concept" in
DateTimeType, "authoritative timezone". If the timezone is authoritative, it means that it correctly represents the source moment in time. If it's non-authoritative, it means that it's a "valid timezone", but might not be the desired one. WhenDateTimeTypes are posted to the event bus, any instances with a non-authoritative timezone will get the OH configured timezone applied, and made authoritative. That way, binding authors don't have to acquire the correct timezone when generating timestamps, but they can specify a timezone that will be preserved if the source is something else, like something read from a device or online API. The same "benefit" also applies to scripts, they can also just useDateTimeType.now()to get an instance with a non-authoritative timezone, that will automatically be converted to the OH configured timezone before entering the even bus.As far as I can tell, this should give "equal relief" to binding authors as the current solution, while avoiding all the negative side effects that exist today.
In addition to "resurrecting timezone handling", I've added a number of "convenience methods" to
DateTimeTypethat should make them easier to use directly, requiring less conversion to other types before manipulation. There typically mirror the ones found on the standard JavaTemporaltypes:truncatedTo(TemporalUnit unit)until(Temporal endExclusive, TemporalUnit unit)until(DateTimeType endExclusive, TemporalUnit unit)plus(TemporalAmount amountToAdd)plus(long amountToAdd, TemporalUnit unit)minus(TemporalAmount amountToSubtract)minus(long amountToSubtract, TemporalUnit unit)isAfter(DateTimeType moment)isAfter(ChronoZonedDateTime<?> moment)isAfter(Instant instant)isBefore(DateTimeType moment)isBefore(ChronoZonedDateTime<?> moment)isBefore(Instant instant)DateTimeTypeis still immutable, so the methods that returnDateTimeTypes, return new instances.Fixes #5354.