Calculating time intervals and synchronization