fix date calculations