calculate maximum time between events