예제 #1
0
        public static int Index(int year, int month, int day)
        {
            ReadingDay first      = _days[0];
            DateTime   firstDate  = first._date;
            DateTime   secondDate = new DateTime(year, month, day);

            return((int)(secondDate - firstDate).TotalDays);
        }
예제 #2
0
 public virtual object Copy()
 {
     ReadingDay copy = new ReadingDay(_date);
     foreach( var reading in Readings )
     {
         copy += reading;
     }
     return copy;
 }
예제 #3
0
        public virtual object Copy()
        {
            ReadingDay copy = new ReadingDay(_date);

            foreach (var reading in Readings)
            {
                copy += reading;
            }
            return(copy);
        }
예제 #4
0
 private static void InsertDaysTo(int index)
 {
     ReadingDay last = _days.Last();
     DateTime date = last._date;
     for(int i = Index(date);i < index;++i)
     {
         date.AddDays(1);
         ReadingDay day = new ReadingDay(date);
         _days.Add(day);
     }
 }
예제 #5
0
        private static void InsertDaysTo(int index)
        {
            ReadingDay last = _days.Last();
            DateTime   date = last._date;

            for (int i = Index(date); i < index; ++i)
            {
                date.AddDays(1);
                ReadingDay day = new ReadingDay(date);
                _days.Add(day);
            }
        }
예제 #6
0
        public static ReadingDay Get(int year, int month, int day)
        {
            int index = Index(year, month, day);

            if (index < 0)
            {
                throw new Exception("Wrong date!");
            }
            if (index >= _days.Count)
            {
                InsertDaysTo(index);
            }
            ReadingDay readingDay = _days[index];

            return(readingDay);
        }