Beispiel #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);
        }
Beispiel #2
0
        public Yearly_Holiday_Viewer(int year)
        {
            InitializeComponent();
            List <DateTime> dates = StatHoliday.GetAllHolidays(year);

            string f = "dddd, MMMM dd";

            l_NewYear.Text        = dates[0].ToString(f);
            l_GoodFriday.Text     = dates[1].ToString(f);
            l_Easter.Text         = dates[2].ToString(f);
            l_VictoriaDay.Text    = dates[3].ToString(f);
            l_CanadaDay.Text      = dates[4].ToString(f);
            l_HeritageDay.Text    = dates[5].ToString(f);
            l_LabourDay.Text      = dates[6].ToString(f);
            l_Thanksgiving.Text   = dates[7].ToString(f);
            l_RemembranceDay.Text = dates[8].ToString(f);
            l_Christmas.Text      = dates[9].ToString(f);
            l_BoxingDay.Text      = dates[10].ToString(f);
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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);
            }
        }