0

I am trying to figure out a pattern that would allow me to keep track of scheduled day ranges and time ranges during a week to make sure that they don't overlap one another when entering into an interface. I was wondering if anyone has ever come across this and has any ideas? Remembering that this does not deal with any datetime values, only DayOfWeek and Timespan. For example, the following schedules are added:

Monday-Saturday: 12:00 AM to 8:00 AM
Monday-Thursday, 8:00 AM to 12:00 PM and 1:00 PM to 6:00 PM
Monday-Thursday, 12:00 PM to 1:00 PM
Monday-Thursday, 1:00 PM to 5:00 PM (this one causes it to error)

My thoughts have been that I could step through the day ranges from the start day to the end day and through the time ranges using some combination of these values that make it unique to add to a dictionary so that if a replication occurs the dictionary throws an exception.

I have to think that something like this has been done before and was wondering if anyone can point me in a direction. I appreciate any comments on this.

James

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • You might consider including this in your day pattern: `"Mon,Wed,Fri"`. I'm curious about your choices of day names. You are allowing `Monday` (non-abbreviated), `Sat` (a standard three-letter abbreviation) and `Thurs` (a five-letter abbreviation that I see rarely used (usually, it's `Thur` or if 3-letter, `Thu`) – Flydog57 Jul 29 '20 at 14:15
  • Flydog57, The day names are just for example. I am actually working with dayofweek (startDay and endDay) and timespan (startTime and endTime) variables. I am not working with DateTime so using the datetime comparisons will not work. This is supposed to be a weekly schedule that my software will follow to determine if a particular service is running or not. So as the example schedule of days and times show I need to know if what the user is entering is overlapping with another scheduled row. – James Wallace Jul 29 '20 at 14:29

0 Answers0