Try the following:
Enter an invalid time for the hour, to see NaN
Take apart the complicated conditional to see what's wrong.