Fix calculation of timestamps larger than 1 hour