Skip to content

Instantly share code, notes, and snippets.

@jmarnold
Created October 4, 2012 04:33
Show Gist options
  • Save jmarnold/3831495 to your computer and use it in GitHub Desktop.
Save jmarnold/3831495 to your computer and use it in GitHub Desktop.
For Gary
public class CurrentScheduleBoundary : ICurrentScheduleBoundary
{
private readonly ISystemTime _systemTime;
private readonly ISchedulingGateway _gateway;
public CurrentScheduleBoundary(ISystemTime systemTime, ISchedulingGateway gateway)
{
_systemTime = systemTime;
_gateway = gateway;
}
public bool Contains(CaseProperties properties)
{
var now = _systemTime.LocalTime();
var schedule = _gateway.GetActiveSchedule();
var boundary = schedule.Period.To;
if(schedule.Period.From.UtcTime.Date == now.UtcTime.Date)
{
return true;
}
if(now.UtcTime.Date > boundary.UtcTime.Date)
{
return false;
}
var scheduledTime = properties.ScheduledTime.Value;
var proposedTime = now.AtTime(scheduledTime);
return boundary > proposedTime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment