calculate distances by time