Fix end time calculation bug.