Given these two Instant Calls previousRun and nextRun, and DateTimeZone is called tz, how would I determine if a localTime called 8AM would fall between the boundaries of this job?
, , . , , , ( , , 8 , ) - :
public static bool ShouldSendEmail(Instant previousRun, Instant nextRun,
DateTimeZone zone)
{
LocalDate date = previousRun.InZone(zone).Date;
LocalDateTime dateTime = date + new LocalTime(8, 0);
Instant instant = dateTime.InZoneLeniently(zone).ToInstant();
return previousRun <= instant && instant < nextRun;
}
InZoneLeniently, , , , : , , 8 .
, , .
EDIT: " ", - previousRun:
public static bool ShouldSendEmail(LocalDateTime nextDate, Instant nextRun,
DateTimeZone zone, LocalTime timeOfDay)
{
LocalDateTime nextEmailLocal = nextDate + timeOfDay;
Instant nextEmailInstant = nextDateTime.InZoneLeniently(zone).ToInstant();
return nextRun > nextEmailInstant;
}
: ", , , ".