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