internal WorkTime Reduce(WorkTime c) { var w = new WorkTime { Hour = this.Hour, Minute = this.Minute }; w.Hour -= c.Hour; w.Minute -= c.Minute; w.Check(); return(w); }
internal WorkTime Append(int hour, int minute) { var w = new WorkTime { Hour = this.Hour, Minute = this.Minute }; w.Hour += hour; w.Minute += minute; w.Check(); return(w); }
public void Load(IDataReader reader) { Id = DataAccessUtility.LoadInt32(reader, "Id"); Month = DataAccessUtility.LoadNullable <DateTime>(reader, "Month"); Active = DataAccessUtility.LoadNullable <bool>(reader, "Active"); var currentMonthTotal = DataAccessUtility.LoadNullable <string>(reader, "CurrentMonthTotal"); if (currentMonthTotal.IsEmpty()) { CurrentMonthTotal = new WorkTime(); } else { CurrentMonthTotal = XmlHelper.CreateFromXml <WorkTime>(currentMonthTotal); } var cfs = DataAccessUtility.LoadNullable <string>(reader, "CurrentShiftStart"); if (cfs.IsEmpty()) { CurrentShiftStart = new WorkTime(); } else { CurrentShiftStart = XmlHelper.CreateFromXml <WorkTime>(cfs); } var cfe = DataAccessUtility.LoadNullable <string>(reader, "CurrentShiftEnd"); if (cfe.IsEmpty()) { CurrentShiftEnd = new WorkTime(); } else { CurrentShiftEnd = XmlHelper.CreateFromXml <WorkTime>(cfe); } }
internal string CurrentShiftTimeLeft(WorkTime required) { if (CurrentShiftStart.NotFilled()) { CurrentShiftStart = new WorkTime(); return(CurrentShiftStart.ToTimeDisplay()); } TimeSpan requiredSpan = new TimeSpan(required.Hour, required.Minute, 0); TimeSpan predEnd = new TimeSpan(CurrentShiftStart.Hour, CurrentShiftStart.Minute, 0) + requiredSpan; TimeSpan actualBalance = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, 0) - new TimeSpan(CurrentShiftStart.Hour, CurrentShiftStart.Minute, 0) - requiredSpan; string balanceStr = actualBalance.ToTimeDisplay(); if (actualBalance > new TimeSpan(0, 0, 0)) // extra hours { balanceStr += " EX"; } return(balanceStr + " | " + new WorkTime { Hour = predEnd.Hours, Minute = predEnd.Minutes }.ToTimeDisplay()); }
public static string ToTimeDisplay(this WorkTime d) { TimeSpan sp = new TimeSpan(d.Hour, d.Minute, 0); return sp.ToString(@"hh\:mm"); }