public static TimeSpan CalcShiftPremium(DateTime start, DateTime end) { if (start.Date == DateTime.MinValue || end.Date == DateTime.MinValue || IsRestDay(start) || StatHoliday.IsStatDay(start)) { return(TimeSpan.Zero); } TimeSpan hoursWorked = CalcHoursWorked(start, end, LunchLength); TimeSpan halfPoint = new TimeSpan(hoursWorked.Ticks / 2); if (start.TimeOfDay >= NightShiftCutoff) { return(CalcHoursWorked(start, end, LunchLength)); } else if (start.TimeOfDay.Add(halfPoint) > NightShiftCutoff) { return(CalcHoursWorked(CombineDateAndTime(start, NightShiftCutoff), end, LunchLength)); } return(TimeSpan.Zero); }
public static TimeSpan CalcWashupTime(DateTime start, DateTime end, TimeSpan lunch) { if (ShiftInformation.IsRestDay(start) || StatHoliday.IsStatDay(start)) { return(ShiftInformation.WashupTimeAmount); } TimeSpan washup = CalcHoursWorked(start, end.AddMinutes(WashupTimeAmount.TotalMinutes), lunch).Subtract(ShiftLength); if (washup < TimeSpan.Zero) { return(TimeSpan.Zero); } else if (washup > WashupTimeAmount) { return(WashupTimeAmount); } else { return(washup); } }
public static TimeSpan CalcOvertime(DateTime start, DateTime end) { if (start.Date == DateTime.MinValue.Date || end.Date == DateTime.MinValue.Date) { return(TimeSpan.Zero); } TimeSpan hoursWorked = CalcHoursWorked(start, end, LunchLength); if (hoursWorked > ShiftLength && !IsRestDay(start) && !StatHoliday.IsStatDay(start)) { return(hoursWorked.Subtract(ShiftLength)); } else if (IsRestDay(start) || StatHoliday.IsStatDay(start)) { return(hoursWorked); } else { return(TimeSpan.Zero); } }