Quartz.Impl.Triggers.DailyTimeIntervalTriggerImpl.ComputeFirstFireTimeUtc C# (CSharp) Method

ComputeFirstFireTimeUtc() public method

This method should not be used by the Quartz client.

Called by the scheduler at the time a ITrigger is first added to the scheduler, in order to have the ITrigger compute its first fire time, based on any associated calendar.

After this method has been called, ITrigger.GetNextFireTimeUtc should return a valid answer.

public ComputeFirstFireTimeUtc ( ICalendar calendar ) : DateTimeOffset?
calendar ICalendar
return DateTimeOffset?
        public override DateTimeOffset? ComputeFirstFireTimeUtc(ICalendar calendar)
        {
            nextFireTimeUtc = GetFireTimeAfter(StartTimeUtc.AddSeconds(-1));

            // Check calendar for date-time exclusion
            while (nextFireTimeUtc != null && calendar != null
                   && !calendar.IsTimeIncluded(nextFireTimeUtc.Value))
            {
                nextFireTimeUtc = GetFireTimeAfter(nextFireTimeUtc);

                if (nextFireTimeUtc == null)
                {
                    break;
                }

                //avoid infinite loop
                if (nextFireTimeUtc.Value.Year > YearToGiveupSchedulingAt)
                {
                    return null;
                }
            }

            return nextFireTimeUtc;
        }