Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Added delay of 1 second if range events are scheduled at same instant
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Kumar Mondal <admin@amitinside.com>
  • Loading branch information
amitjoy committed Jun 27, 2017
1 parent 04a064c commit 005dae2
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 005dae2

Please sign in to comment.