Dynamical systems that compute time-optimal switchings