Exemple #1
0
        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);
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
            }
        }