/// <summary> /// Вычисляет следующую точку периода на основании предыдущей. /// </summary> /// <param name="lastLaunch">Предыдущая дата.</param> /// <returns>Следующее значение периодичности по дате.</returns> public override DateTime?GetNextLaunching(DateTime?lastLaunch) { DateTime current = DateTime.Now; DateTime point = lastLaunch.HasValue ? lastLaunch.Value.Date : DurationFrom.AddDays(NearestIncreementFor(DurationFrom.AddDays(-1))); while (point < current.Date) { point = point.AddDays(NearestIncreementFor(point)); } if (DailyFrequency.IsSingleLanch) { point = point.Add(DailyFrequency.StartingAt); if (lastLaunch.HasValue) { if (lastLaunch.Value.Date == DateTime.Now.Date) { point = point.AddDays(NearestIncreementFor(point)); } } } else { TimeSpan time = lastLaunch.HasValue ? lastLaunch.Value.TimeOfDay : current.TimeOfDay; TimeSpan?nextTime = DailyFrequency.GetNextTimeLaunching(time); point = nextTime.HasValue ? point.Add(nextTime.Value) : point.AddDays(NearestIncreementFor(point)).Add(DailyFrequency.StartingAt); } return(point > DurationTo ? default(DateTime?) : point); }
/// <summary> /// Вычисляет следующую точку периода на основании предыдущей. /// </summary> /// <param name="lastLaunch">Предыдущая дата.</param> /// <returns>Следующее значение периодичности по дате.</returns> public override DateTime?GetNextLaunching(DateTime?lastLaunch) { if (lastLaunch.HasValue) { return(default(DateTime?)); } var next = DurationFrom.Add(DailyFrequency.StartingAt); return(next <= DateTime.Now ? default(DateTime?) : next); }