added cleanup_datetime function