timespan calculation and formatting