Compare times

from 5:00 p.m. to 10:00 p.m.

Looks wrong

Do you mean if the hour is less than 05:00 or the hour is greater than 22:00 display "Close window"