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

Adapt DateTimeType internal switch from ZonedDateTime to Instant in openHAB 4.3 #369

Merged
merged 1 commit into from
Dec 28, 2024

Conversation

jimtng
Copy link
Contributor

@jimtng jimtng commented Dec 16, 2024

No description provided.

@jimtng jimtng added the bug Something isn't working label Dec 16, 2024
@jimtng jimtng force-pushed the datetimetype-zdt2 branch 5 times, most recently from 00dfdf7 to d051346 Compare December 16, 2024 09:14
@@ -48,7 +48,17 @@ def parse(time_string)
# fields during conversion. Not used in this class.
# @return [ZonedTimeTime]
def to_zoned_date_time(context = nil) # rubocop:disable Lint/UnusedMethodArgument
zoned_date_time
# @deprecated OH 4.2 Just call zoned_date_time(ZoneId.system_default) in OH 4.3
unless instance_variable_defined?(:@zoned_date_time_method)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really inefficient to have to create a method object for every instance of DateTimeType. Instead, do a conditional outside the method, and then define the method (literally) as appropriate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!

@jimtng jimtng force-pushed the datetimetype-zdt2 branch 5 times, most recently from 862aee6 to b8e0eb3 Compare December 17, 2024 03:19
@jimtng jimtng changed the title Avoid calling the deprecated DateTimeType.getZonedDateTime() Adapting DateTimeType internal switch from ZonedDateTime to Instant in openHAB 4.3 Dec 17, 2024
@jimtng jimtng changed the title Adapting DateTimeType internal switch from ZonedDateTime to Instant in openHAB 4.3 Adapt DateTimeType internal switch from ZonedDateTime to Instant in openHAB 4.3 Dec 17, 2024
@jimtng
Copy link
Contributor Author

jimtng commented Dec 17, 2024

This PR has merits beyond just avoiding the deprecation of DateTimeType.getZonedDateTime(), because we're trying to avoid unnecessary conversions to ZonedDateTime when Instant would do.

@jimtng jimtng force-pushed the datetimetype-zdt2 branch 2 times, most recently from e780346 to 3221324 Compare December 17, 2024 04:08
@ccutrer ccutrer merged commit 3842e0e into openhab:main Dec 28, 2024
26 checks passed
@jimtng jimtng deleted the datetimetype-zdt2 branch December 29, 2024 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants