Esempio n. 1
0
        /// <summary>
        /// This is used to find the starting point for the secondly frequency
        /// </summary>
        /// <param name="r">A reference to the recurrence</param>
        /// <param name="start">The recurrence start date</param>
        /// <param name="end">The recurrence end date</param>
        /// <param name="from">The start date of the range limiting the instances generated</param>
        /// <param name="to">The end date of the range limiting the instances generated</param>
        /// <returns>The first instance date or null if there are no more instances</returns>
        public RecurDateTime FindStart(Recurrence r, RecurDateTime start, RecurDateTime end, RecurDateTime from,
                                       RecurDateTime to)
        {
            RecurDateTime rdt = new RecurDateTime(start);
            int           adjust;

            if (RecurDateTime.Compare(start, from, RecurDateTime.DateTimePart.Hour) < 0)
            {
                // Get the difference between the recurrence start and the limiting range start
                DateTime dtStart = start.ToDateTime(), dtFrom = from.ToDateTime();

                // Adjust the date/time so that it's in range
                TimeSpan ts = dtFrom - dtStart;

                adjust = (int)ts.TotalSeconds + r.Interval - 1;
                rdt.AddSeconds(adjust - (adjust % r.Interval));
            }

            if (RecurDateTime.Compare(rdt, end, RecurDateTime.DateTimePart.Hour) > 0 ||
                RecurDateTime.Compare(rdt, to, RecurDateTime.DateTimePart.Hour) > 0)
            {
                return(null);
            }

            return(rdt);
        }
Esempio n. 2
0
        /// <summary>
        /// This is used to find the next instance of the secondly frequency
        /// </summary>
        /// <param name="r">A reference to the recurrence</param>
        /// <param name="end">The recurrence end date</param>
        /// <param name="to">The end date of the range limiting the instances generated</param>
        /// <param name="last">This is used to pass in the last instance date calculated and return the next
        /// instance date</param>
        /// <returns>True if the recurrence has another instance or false if there are no more instances</returns>
        public bool FindNext(Recurrence r, RecurDateTime end, RecurDateTime to, RecurDateTime last)
        {
            last.AddSeconds(r.Interval);

            if (last > end || last > to)
            {
                return(false);
            }

            return(true);
        }