Fix error with dateToString method