fix date calculation