Esempio n. 1
0
        public static bool IsActiveOnDay(this DaysFlag mask, DateTime day)
        {
            switch (day.DayOfWeek)
            {
            case DayOfWeek.Monday:
                return(mask.HasFlag(DaysFlag.Monday));

            case DayOfWeek.Tuesday:
                return(mask.HasFlag(DaysFlag.Tuesday));

            case DayOfWeek.Wednesday:
                return(mask.HasFlag(DaysFlag.Wednesday));

            case DayOfWeek.Thursday:
                return(mask.HasFlag(DaysFlag.Thursday));

            case DayOfWeek.Friday:
                return(mask.HasFlag(DaysFlag.Friday));

            case DayOfWeek.Saturday:
                return(mask.HasFlag(DaysFlag.Saturday));

            case DayOfWeek.Sunday:
                return(mask.HasFlag(DaysFlag.Sunday));

            default:
                throw new ArgumentOutOfRangeException($"Unhandled day {day.DayOfWeek} - {day}");
            }
        }
Esempio n. 2
0
 public CifCalendar(DateTime runsFrom, DateTime runsTo, DaysFlag days, BankHolidayRunning bankHolidays)
 {
     RunsFrom     = runsFrom;
     RunsTo       = runsTo;
     DayMask      = days;
     BankHolidays = bankHolidays;
 }
Esempio n. 3
0
        public static ICalendar CreateAugust2019Calendar(DaysFlag dayMask = DaysFlag.Everyday,
                                                         BankHolidayRunning bankHolidays = BankHolidayRunning.RunsOnBankHoliday)
        {
            var calendar = new CifCalendar(
                new DateTime(2019, 8, 1),
                new DateTime(2019, 8, 31),
                dayMask,
                bankHolidays);

            calendar.Generate();
            return(calendar);
        }
Esempio n. 4
0
        public static string ToStringEx(this DaysFlag flag)
        {
            var s = new StringBuilder();

            if (flag.HasFlag(DaysFlag.Monday))
            {
                s.Append("Mo");
            }
            if (flag.HasFlag(DaysFlag.Tuesday))
            {
                s.Append("Tu");
            }
            if (flag.HasFlag(DaysFlag.Wednesday))
            {
                s.Append("We");
            }
            if (flag.HasFlag(DaysFlag.Thursday))
            {
                s.Append("Th");
            }
            if (flag.HasFlag(DaysFlag.Friday))
            {
                s.Append("Fr");
            }
            if (flag.HasFlag(DaysFlag.Saturday))
            {
                s.Append("Sa");
            }
            if (flag.HasFlag(DaysFlag.Sunday))
            {
                s.Append("Su");
            }

            var o = s.ToString();

            return(o == "" ? "None" : o);
        }
Esempio n. 5
0
 public void MapDaysMask(string source, DaysFlag expected)
 {
     Assert.Equal(expected, CalendarConverter.MapMask(source));
 }
Esempio n. 6
0
 public void IsActiveOnSpecificDay(DaysFlag flag, int increment)
 {
     Assert.True(flag.IsActiveOnDay(Friday.AddDays(increment)));
 }
Esempio n. 7
0
 public void DaysFlagToStingEx(DaysFlag days, string expected)
 {
     Assert.Equal(expected, days.ToStringEx());
 }