Ejemplo n.º 1
0
        public static IEnumerable <TimeBucket <TCalendar> > GetBuckets(DateTime start, DateTime end, DatePart datePart,
                                                                       bool startingPartial = false, bool endingPartial = false)
        {
            var timeBuckets = new List <TimeBucket <TCalendar> >();
            var firstBucket = new TimeBucket <TCalendar>(start, datePart, partialStart: startingPartial);
            var lastBucket  = new TimeBucket <TCalendar>(end, datePart, partialEnd: endingPartial);
            TimeBucket <TCalendar> current;

            if (firstBucket.Given == firstBucket.StartPoint || startingPartial)
            {
                timeBuckets.Add(firstBucket);
                current = firstBucket.Clone();
            }
            else
            {
                current = firstBucket.AddDatePart(1).Clone();
            }

            if (lastBucket.Given != lastBucket.EndPoint && !endingPartial)
            {
                lastBucket.AddDatePart(-1);
            }

            while (current.EndPoint < lastBucket.StartPoint)
            {
                timeBuckets.Add(current.AddDatePart(1).Clone());
            }

            timeBuckets.Add(lastBucket);

            return(timeBuckets);
        }
Ejemplo n.º 2
0
 public int CompareTo(TimeBucket <TCalendar> other)
 {
     return(StartPoint.CompareTo(other.StartPoint));
 }