Check that dates are valid.