public static DateTime CreateDailyDueTime(DailyTime dailyTime, DateTime?lastRunTime = null) { var hour = dailyTime.Hour; var minute = dailyTime.Minute; var second = dailyTime.Second; var todayUtc = (lastRunTime ?? DateTime.UtcNow); var year = todayUtc.Year; var month = todayUtc.Month; var day = todayUtc.Day; var trialDate = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc); if (trialDate < todayUtc) { return(trialDate.AddDays(1)); } return(trialDate); }
/// <summary> /// Only run the job between the specified start and end times. /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <remarks>We use timespans to represent </remarks> /// <returns></returns> public IntervalJobSchedule WithRunPeriod(DailyTime from, DailyTime to) { this._startTime = from; this._stopTime = to; return(this); }