Not sure how to approach this. I have an app where users can select a time range (say 5:00 PM to 10:00 AM) that repeats daily based on the days selected by the user (say Mon, Thurs, and Sat). How can I determine if the current time is within one of these ranges?
Edit:
I took a look at Find if current time falls in a time range, but I don't think this is a duplicate because it doesn't address the issue I am getting confused on. For example, I'm not sure what to do when a time range falls into the next day. Like in my example, how would I handle 5:00 PM to 10:00 AM the next day? What about when it falls into the next week like from Sat to Sun (which would be 6 to 0)?
More Info:
I am not working with DateTime objects, I am working with the DaysOfWeek enum and and Timespans to represent the time. Below is a representation of the ranges I would be working with:
| startDay | startTime | endDay | endTime | |----------|-----------|--------|-----------| | 1 | 17:00:00 | 2 | 09:00:00 | | 3 | 09:00:00 | 3 | 17:00:00 | | 6 | 17:00:00 | 0 | 09:00:00 |