I don’t know if am am loosing my mind or if this is even possible.
By the way, I am not using any standard libraries so this is not language dependent, hence why it’s here and not on stackoverflow.
I have 2 time periods that are being passed to me in a int format.
1st period-
Start Time:
End Time:
2nd period-
Start Time:
End Time:
The Int’s are minutes since midnight, so 7am would be 420 minutes.
So an example of a function I am trying to write is:
bool SpanMoreThan24Hours(int firstStartTime, int firstEndTime,
int secondStartTime, int secondEndTime)
{
....
}
I am not even sure this can be done.
P.S. Spanning midnight is fine, but it doesn’t have to.
Periods can’t overlap.
So it could look like this:
420, 1140, 1260, 419
7am, 7pm, 9pm, 6:59am
- Valid
This would be valid since it doesn't span over 24 hours.
420, 1140, 1260, 421
7am, 7pm, 9pm, 7:01am
- Not valid
420, 60, 120, 419
7am, 1am,2am, 6:59am
- Valid
I have to make sure from 1st period start time till 2nd period end time is not over 24 hours.
If a period can start on monday and end on wednesday, there is no solution to the problem; otherwise, here is some C# to you: