From 005dae20b8150cdd042154a1a1930f1ff1e6d172 Mon Sep 17 00:00:00 2001 From: Amit Kumar Mondal Date: Tue, 27 Jun 2017 13:03:07 +0200 Subject: [PATCH] Added delay of 1 second if range events are scheduled at same instant Signed-off-by: Amit Kumar Mondal --- .../smarthome/binding/astro/internal/job/Job.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/extensions/binding/org.eclipse.smarthome.binding.astro/src/main/java/org/eclipse/smarthome/binding/astro/internal/job/Job.java b/extensions/binding/org.eclipse.smarthome.binding.astro/src/main/java/org/eclipse/smarthome/binding/astro/internal/job/Job.java index 6c805a82051..138adafadd7 100644 --- a/extensions/binding/org.eclipse.smarthome.binding.astro/src/main/java/org/eclipse/smarthome/binding/astro/internal/job/Job.java +++ b/extensions/binding/org.eclipse.smarthome.binding.astro/src/main/java/org/eclipse/smarthome/binding/astro/internal/job/Job.java @@ -7,6 +7,7 @@ */ package org.eclipse.smarthome.binding.astro.internal.job; +import static java.util.Calendar.SECOND; import static java.util.Objects.isNull; import static org.apache.commons.lang.time.DateFormatUtils.ISO_DATETIME_FORMAT; import static org.eclipse.smarthome.binding.astro.AstroBindingConstants.*; @@ -39,7 +40,7 @@ public interface Job extends Runnable { /** Logger Instance */ public final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - + /** * Schedules the provided {@link Job} instance * @@ -111,8 +112,15 @@ public static void scheduleRange(String thingUID, AstroThingHandler astroHandler if (thingNull || astroHandlerNull || rangeNull || channelIdNull) { return; } - scheduleEvent(thingUID, astroHandler, range.getStart(), EVENT_START, channelId); - scheduleEvent(thingUID, astroHandler, range.getEnd(), EVENT_END, channelId); + + //add 1 second to the last scheduled event if both the events comprise same time instant + Calendar start = range.getStart(); + Calendar end = range.getEnd(); + if (truncatedEquals(start, end, SECOND)) { + end.add(SECOND, 1); + } + scheduleEvent(thingUID, astroHandler, start, EVENT_START, channelId); + scheduleEvent(thingUID, astroHandler, end, EVENT_END, channelId); } /**