Dedicated function to compute time period