fixed bug in writing dates to string