update to the time_clean function by Jean-Edouard Babin