I shall be perfectly honest, I don't know a thing about jquery, and thereby can only offer general advice.
Is the order 'fixed'?
As in: In field one is always the open time, in field two is always the closing time?
If so, the answer is fairly simple...when Field two is smaller than field one, add a 'special case'.
Instead of checking 'timestamp > openTime && timestamp < closeTime' check for:
if(timestamp > openTime && timestamp <= Midnight || timestamp >= 0 && timestamp < closing time) {
//Open/Close time
}
May this help?
A more complete code sample may be:
if((closeTime > openTime && timestamp > openTime && timestamp < closeTime) || //Normal time
(timestamp > openTime && timestamp < 86399) || //Before Midnight
(timestamp > 0 && timestamp < closeTime)) { //After Midnight
//Do Stuff
}
'closeTime' you'd have to make sure that you're always checking the correct weekday, like Jon Taylor already stated...but to be perfectly honest, you're probably best off with his solution.
Alternatively, you'd have to check, assuming your day time is after midnight...and before open time of THIS weekday, if this rule applies to the previous day's closing time.
Just to clarify this in code:
if(timestamp < openTime && openTimePrevDay > closeTimePrevDay && timestamp > closeTimePrevDay) {
//Bar is open
}
Get what I mean?