From: Hilbrand Bouwkamp Date: Thu, 30 Dec 2021 12:49:43 +0000 (+0100) Subject: [astro] Fixed timeLeft calculation at the end of the year (#11889) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=253f36abbf3ac5e9f5b0657ffc9b4f995c45947c;p=openhab-addons.git [astro] Fixed timeLeft calculation at the end of the year (#11889) Season timeleft calculated the wrong time at the end of the year, because the seasons it measures the time with are the seasons within the same year. So for times at the end of the year it computed against the season at the beginning of the year, resulting in negative number of days. Also changed the time of timeLeft to actual days instead of quantity unit days. Because with the milliseconds internal resolution it will generate events each and every time this channel is updated as milliseconds change often. Signed-off-by: Hilbrand Bouwkamp --- diff --git a/bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/model/Season.java b/bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/model/Season.java index e2f3e4418d..00cfa2752f 100644 --- a/bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/model/Season.java +++ b/bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal/model/Season.java @@ -12,8 +12,8 @@ */ package org.openhab.binding.astro.internal.model; -import static org.openhab.core.library.unit.MetricPrefix.MILLI; - +import java.time.Duration; +import java.time.temporal.ChronoUnit; import java.util.Calendar; import javax.measure.quantity.Time; @@ -127,9 +127,10 @@ public class Season { * Returns the time left for current season */ public QuantityType