Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public virtual object Copy()
 {
     ReadingDay copy = new ReadingDay(_date);
     foreach( var reading in Readings )
     {
         copy += reading;
     }
     return copy;
 }
Exemplo n.º 3
0
        public virtual object Copy()
        {
            ReadingDay copy = new ReadingDay(_date);

            foreach (var reading in Readings)
            {
                copy += reading;
            }
            return(copy);
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
        }