Fixed date calculation bug