/// <summary>
        /// Distance from one day of week to another in days
        /// </summary>
        public static int DistanceTo(this RepetitionDayOfWeek fromDayOfWeek, RepetitionDayOfWeek toDayOfWeek)
        {
            var fromIndex = daysOfWeek.BinarySearch(fromDayOfWeek);
            var toIndex   = daysOfWeek.BinarySearch(toDayOfWeek);

            if (toIndex > fromIndex)
            {
                return(toIndex - fromIndex);
            }

            return(7 - fromIndex + toIndex);
        }
        public static RepetitionDayOfWeek GetNextRepetitionDayOfWeek(this RepetitionDayOfWeek dayOfWeek, RepetitionDayOfWeek repetition)
        {
            if (repetition == RepetitionDayOfWeek.Empty)
            {
                return(RepetitionDayOfWeek.Empty);
            }

            var nextRepetitionDayOfWeek = dayOfWeek.GetNextDayOfWeek();

            while (!IsInRepetition(nextRepetitionDayOfWeek, repetition))
            {
                nextRepetitionDayOfWeek = nextRepetitionDayOfWeek.GetNextDayOfWeek();
            }

            return(nextRepetitionDayOfWeek);
        }
 public static bool IsInRepetition(this RepetitionDayOfWeek dayOfWeek, RepetitionDayOfWeek repetition)
 {
     return(repetition.HasFlag(dayOfWeek));
 }
 public static bool IsRepetitionToday(this IScheduler scheduler, RepetitionDayOfWeek repetition)
 {
     return(scheduler.GetCurrentDayOfWeek().IsInRepetition(repetition));
 }
        private static RepetitionDayOfWeek GetNextDayOfWeek(this RepetitionDayOfWeek dayOfWeek)
        {
            var index = daysOfWeek.BinarySearch(dayOfWeek);

            return(daysOfWeek[(index + 1) % 7]);
        }
 public static IEnumerable <RepetitionDayOfWeek> GetDaysOfWeek(this RepetitionDayOfWeek repetition)
 {
     return(daysOfWeek.Where(x => x.IsInRepetition(repetition)));
 }
 public static string GetShortName(this RepetitionDayOfWeek dayOfWeek)
 {
     return(shortNames.TryGetValue(dayOfWeek, out var shortName)
         ? shortName
         : string.Join(", ", dayOfWeek.GetDaysOfWeek().Select(x => shortNames[x])));
 }
 public static string GetName(this RepetitionDayOfWeek dayOfWeek)
 {
     return(names[dayOfWeek]);
 }