/*
 * Copyright (c) 2015, Turn Inc. All Rights Reserved.
 * Use of this source code is governed by a BSD-style license that can be found
 * in the LICENSE file.
 */

package com.turn.sorcerer.dependency.impl;

import com.turn.sorcerer.dependency.Dependency;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.joda.time.DateTime;

/**
 * Class Description Here
 *
 * @author tshiou
 */
public class TimeDependency implements Dependency {
	private static final Logger logger =
			LogManager.getFormatterLogger(TimeDependency.class);

	private DateTime scheduledTime;

	public TimeDependency(DateTime dateTime) {
		this.scheduledTime = dateTime;
	}

	@Override
	public boolean check(int iterNo) {

		int scheduledHour = scheduledTime.getHourOfDay();
		int scheduledMinute = scheduledTime.getMinuteOfHour();

		// Compare with current time
		DateTime calendar = new DateTime();
		int currentHour = calendar.getHourOfDay();
		int currentMinute = calendar.getMinuteOfHour();

		if (currentHour > scheduledHour ||
				(currentHour == scheduledHour && currentMinute >= scheduledMinute)) {
			logger.info("Time dependency success at %s %s", currentHour, currentMinute);
			return true;
		}

		return false;
	}

	@Override
	public String toString() {
		return "Time : " + scheduledTime.getHourOfDay() + ":" + scheduledTime.getMinuteOfHour();
	}
}

@@ -267,142 +267,255 @@
 org.
-apache.logging.log4j.LogManager;%0Aimport org.apache.logging.log4j.Logger;%0Aimport org.joda.time.DateTime;%0A%0A/**%0A * Class Description Here
+joda.time.DateTime;%0A%0A/**%0A * Time of day task dependency.%0A *%0A * %3Cp%3E%0A * This implementation of %7B@link Dependency%7D should be used if a task should%0A * be scheduled after a certain time of day. This implementation uses the%0A * Joda-Time library.%0A * %3C/p%3E
 %0A *%0A
@@ -588,16 +588,17 @@
 dency %7B%0A
+%0A
 %09private
@@ -602,102 +602,13 @@
 ate 
-static final Logger logger =%0A%09%09%09LogManager.getFormatterLogger(TimeDependency.class);%0A%0A%09private
+final
  Dat
@@ -661,20 +661,25 @@
 ateTime 
-date
+scheduled
 Time) %7B%0A
@@ -705,12 +705,17 @@
 e = 
-date
+scheduled
 Time
@@ -771,510 +771,44 @@
 ) %7B%0A
-%0A
 %09%09
-int scheduledHour = scheduledTime.getHourOfDay();%0A%09%09int scheduledMinute = scheduledTime.getMinuteOfHour();%0A%0A%09%09// Compare with current time%0A%09%09DateTime calendar = new DateTime();%0A%09%09int currentHour = calendar.getHourOfDay();%0A%09%09int currentMinute = calendar.getMinuteOfHour();%0A%0A%09%09if (currentHour %3E scheduledHour %7C%7C%0A%09%09%09%09(currentHour == scheduledHour && currentMinute %3E= scheduledMinute)) %7B%0A%09%09%09logger.info(%22Time dependency success at %25s %25s%22, currentHour, currentMinute);%0A%09%09%09return true;%0A%09%09%7D%0A%0A%09%09return false
+return scheduledTime.isBeforeNow()
 ;%0A%09%7D

Add javadocs to TimeDependency