Add more robust handling of hour/day transitions.