Fix conversion of datetime object to str