fixes to date calculation