public void ShouldFormattedDatesNTimes() { DayInfo day = new DayInfo("20101201;001122;012345"); Assert.AreEqual <string>("01/12", day.GetFormattedDay()); Assert.AreEqual <string>("00:11:22", day.GetFormattedFirstActivity()); Assert.AreEqual <string>("01:23:45", day.GetFormattedLastActivity()); Assert.AreEqual <string>("01", day.GetDay()); Assert.AreEqual <string>("201012", day.GetMonth()); Assert.AreEqual <string>("20101201", day.GetDateToString()); }
public DayInfoRow GetTodayRow() { DateTime first = today.getFirstActivity().Value; DateTime expected = first.AddMinutes(config.Workload - config.Tolerance); if (config.Subtract) { if (config.SubtractCondition == -1) { expected = expected.AddMinutes(config.SubtractQuantity); } else if (config.SubtractCondition == 0) { if (today.getFirstActivity().Value.TimeOfDay.TotalHours < 12 && expected.TimeOfDay.TotalHours > 12) { expected = expected.AddMinutes(config.SubtractQuantity); } } } return(new DayInfoRow(today.GetMonth(), today.GetDay() + " / " + today.GetMonth().Substring(4), today.GetWeekday(), today.GetFormattedFirstActivity(), today.GetFormattedLastActivity(), Utils.MinutesToString(Diff), Utils.MinutesToString(Net), (RoundedDelta? "•" : "") + Utils.MinutesToString(Delta), Utils.DatetimeToTime(expected), today.GetComment())); }
public void CalcMonth() { AverageDelta = AverageDifference = AverageEnd = AverageNet = AverageStart = TotalDelta = TotalNet = 0; dataset = new List <DayInfoRow>(); List <string> files = io.ListAllFiles(month.getSubDirectory()); foreach (string filename in files.OrderByDescending(o => o).ToList()) { DayInfo day = new DayInfo(io.ReadFromFile(month.getSubDirectory(), filename)); DateTime first = (DateTime)day.getFirstActivity(); DateTime last = (DateTime)day.getLastActivity(); int worked = (int)(last - first).TotalMinutes; AverageDifference += worked; AverageStart += (int)first.TimeOfDay.TotalSeconds; AverageEnd += (int)last.TimeOfDay.TotalSeconds; int raw = worked; if (config.Subtract) { if (config.SubtractCondition == -1) { worked -= config.SubtractQuantity; } else if (config.SubtractCondition == 0) { if (first.TimeOfDay.TotalHours < 12 && last.TimeOfDay.TotalHours > 12) { worked -= config.SubtractQuantity; } } else { if (worked > config.SubtractCondition) { worked -= config.SubtractQuantity; } } } int delta = worked - config.Workload; bool rounded = false; if (delta >= -config.Tolerance && delta <= config.Tolerance) { delta = config.Workload; rounded = true; } TotalNet += worked; TotalDelta += delta; dataset.Add(new DayInfoRow(day.GetMonth(), day.GetDay(), day.GetWeekday(), Utils.SecondsToString((int)first.TimeOfDay.TotalSeconds), Utils.SecondsToString((int)last.TimeOfDay.TotalSeconds), Utils.MinutesToString(raw), Utils.MinutesToString(worked), (rounded? "•" : "") + Utils.MinutesToString(delta), "", day.GetComment())); } if (files.Count > 0) { AverageStart /= files.Count; AverageEnd /= files.Count; AverageDifference /= files.Count; AverageNet = TotalNet / files.Count; AverageDelta = TotalDelta / files.Count; } }