Calculation of elapsed time