fix calculation of milliseconds to midnight