I have a service that user can configure to run during \"off-peak\" hours. They have the ability to set the time frame that the service can run.
For Example:
So I assume from the question that you want to know if given a start time and end time for a day (not including the actual date, i.e., 1/1/1900 or something like that) to see if another time is with the time specified by start and end. E.g., if start is 9pm and end is 9am, accept 10pm but reject 10am.
You can do this either per time range types (times are equal, end is after start, end is before start) which is simple:
if (end==start) return true
else if (end>start) return start<=time && time<=end
else return !(time>end && time
Or you can extend the range of start and end such that end is always after start as such:
if (end<=start) end += <24 hours>
if (time
return time<=end