private DayStatistics(int daysAgo, RedmineApi.RedmineXmlGetter getter) { _getter = getter; _watch = new Stopwatch(); double daysToSubtract = -daysAgo; _day = (int)DateTime.Today.AddDays(-daysAgo).DayOfWeek; _time = _getter.getWorkedHoursInDate(DateTime.Today.AddDays(-daysAgo)); }
/// <summary> /// Get the amount of hours worked on the last 7 days. /// </summary> /// <param name="getter">RedmineXmlGetter instance</param> /// <returns>List of last 7 days (including today).</returns> public static List <DayStatistics> getPastWeek(RedmineApi.RedmineXmlGetter getter) { List <DayStatistics> days = new List <DayStatistics>(); DayStatistics today = new DayStatistics(); today._day = (int)DateTime.Today.DayOfWeek; today._time = getter.getWorkedHoursInDate(DateTime.Today); days.Add(today); for (int i = 1; i < 7; i++) { days.Add(new DayStatistics(i, getter)); } return(days); }