-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[astro] Fix returning wrong sun phase name #14078
Conversation
Signed-off-by: lsiepel <leosiepel@gmail.com>
Signed-off-by: lsiepel <leosiepel@gmail.com>
Signed-off-by: lsiepel <leosiepel@gmail.com>
Signed-off-by: lsiepel <leosiepel@gmail.com>
Signed-off-by: lsiepel <leosiepel@gmail.com>
Signed-off-by: lsiepel <leosiepel@gmail.com>
Signed-off-by: lsiepel <leosiepel@gmail.com>
....openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/model/MoonPhase.java
Outdated
Show resolved
Hide resolved
Signed-off-by: lsiepel <leosiepel@gmail.com>
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, thank you
Is it something we should cherry-pick in 3.4.x ? |
@lsiepel - good job hunting and nailing this long-time bug! @lolodomo - I'm not sure. It's an equation of risk vs. impact. It seems this bug happens rarely (next time May?), but how sure are we that this fix will not cause any regressions? Perhaps we should leave it for 4.0 so we would have a full release cycle for detecting any regressions. I didn't look closely into the details, but please correct me if you believe the risk is negligible. |
Ok |
Agree, hope the milestones will get some feedback. |
* Add tests and fix very minor bug * Correct wrong test * Update tests and fix sorting * Some checkstyle improvements Signed-off-by: lsiepel <leosiepel@gmail.com>
* Add tests and fix very minor bug * Correct wrong test * Update tests and fix sorting * Some checkstyle improvements Signed-off-by: lsiepel <leosiepel@gmail.com>
* Add tests and fix very minor bug * Correct wrong test * Update tests and fix sorting * Some checkstyle improvements Signed-off-by: lsiepel <leosiepel@gmail.com>
While troubleshooting issue 7642 first a minor bug was found in the calculation of sun phases.
In
Sun.getSunInfo
method for each phase (sunrise, sunset etc.) a range (start/end datetime) where that phase is valid for is calculated. At the end of all the calculations the current datetime instead of the method parameter was checked against these ranges to determine the current phase.This behavior is for almost all use-cases perfectly fine as the binding usually only shows the current sun phase. But when performing unit tests, this limits you to the current date and prevents you from checking historical phases etc. So, i changed it to the method parameter.
Also added three tests related to the issue. This revealed that the Map holding the ranges for all subphases is not sorted. giving strange results when null values get involved.
So, two fixes:
Calendar.Instance
(now)Closes #7642
Closes #12746
Closes #12767