Based on my unit-test I’m trying to calculate when the next instance of 0400 hrs are and return this;
public void when_given_a_date_i_should_return_next_time_of_day_that_equals_04_hrs()
{
var dateTimeNow = new DateTime(2012, 6, 11, 14, 22, 0);
var dateTimeExpected = new DateTime(2012, 6, 12, 4, 0, 0);
Assert.AreEqual(dateTimeExpected, t.CalculateIncremental(dateTimeNow));
}
The point of CalculateIncremental is to publish a message with nservicebus every 24 hrs, at exactly 04:00 am using RequestUtcTimeout. This again to trigger some functionality.
Something like this:
Should return the next occurrence of 4 AM, which can be on the same day (if the input is earlier than 04:00) or the next. However:
You should use a scheduler for that, like Quartz.NET or simply the Windows Task Scheduler.