Example #1
0
 public DayRange(DayPoint start, DayPoint end)
 {
     //Debug.Assert(start.Year <= end.Year);
     //Debug.Assert(start.Day <= end.Day);
     this.startDay = start;
     this.endDay   = end;
 }
        public bool Equals(DayPoint other)
        {
            if (Object.ReferenceEquals(other, null))
            {
                return(false);
            }
            if (Object.ReferenceEquals(other, this))
            {
                return(true);
            }

            if (other.GetType() != this.GetType())
            {
                return(false);
            }

            return((other.Day == Day) && (other.Year == Year));
        }
Example #3
0
        public void ForEach(Action <DayPoint> action)
        {
            DayPoint current  = StartDay;
            DateTime yearDate = new DateTime(current.Year, 12, 31);

            while (current != endDay)
            {
                action.Invoke(current);


                if (current.Day == yearDate.DayOfYear)
                {
                    current  = new DayPoint(current.Year + 1, 1);
                    yearDate = new DateTime(current.Year, 12, 31);
                }
                else
                {
                    current = new DayPoint(current.Year, current.Day + 1);
                }
            }
        }
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            DayPoint other = obj as DayPoint;

            if (other == null)
            {
                throw new ArgumentException($"It's not a {nameof(DayPoint)}");
            }

            var yearDiff = Year - other.Year;

            if (yearDiff != 0)
            {
                return(yearDiff);
            }

            return(Day - other.Day);
        }