Fix the defect of calculating time