In the above code block, the first assignment to $hour sets it to 0;
The second assignment sets it to 23.
The conditional statement then adds 23 hours to the date instance.
I'm not sure what was intended here, but any DST correction should never exceed 1 hour.