fix date handling bugs