Beispiel #1
0
        /// <summary>
        /// Retrieves the recurrence, after applying the specified name format.
        /// </summary>
        /// <remarks>
        /// Multiple zones may apply the same set of rules as to when they change into/out of
        /// daylight saving time, but with different names.
        /// </remarks>
        /// <param name="zone">The zone for which this rule is being considered.</param>
        public IEnumerable <ZoneRecurrence> GetRecurrences(ZoneLine zone)
        {
            string name = zone.FormatName(recurrence.Savings, daylightSavingsIndicator);

            if (Type == null)
            {
                yield return(recurrence.WithName(name));
            }
            else
            {
                Predicate <int> yearPredicate = GetYearPredicate();
                // Apply a little sanity...
                if (recurrence.IsInfinite || recurrence.ToYear - recurrence.FromYear > 1000)
                {
                    throw new NotSupportedException("Noda Time does not support 'typed' rules over large periods");
                }
                for (int year = recurrence.FromYear; year <= recurrence.ToYear; year++)
                {
                    if (yearPredicate(year))
                    {
                        yield return(recurrence.ForSingleYear(year).WithName(name));
                    }
                }
            }
        }