Fix time wrapping over midnight issue.