I have many companies each one have a opening date and a closing date ex :
Company Open Close
A 08.00 22.00 (close in the **same** day)
B 10.00 02.00 (close in the **second** day)
C 14.00 03.00 (close in the **second** day)
On the web page the user must see a list of the companies and show the status of each one (open or close) depending on the current time (SERVER TIME)
THE PROBLEM :
when the company open and close in the same day ( A ) it’s easy to get the status
in the following algorithm : isOpen = (NOW > OpenTime AND NOW < ClosingTime)
, but if the company open in day 1 and close in day 2 ( B , C ) if the user check the page at 1.00 the company B will appear closed (because (1.00 > 10.00 AND 1.00 < 02.00) is False ) but in real time its opened.
How can I resolve this issue (when the closing time day is different than the opening time day)
The easiest solution I can think of would be to check if the close time listed is less than the open time and add 24 hours, and check against that value