-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
fix: Validate constructed date has year within typemin/max #54933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, this looks mostly mergeable to me, but I'm not sure what the len changes are for.
hi -= st # Prevent overshooting | ||
while v <= hi && prev <= v | ||
prev = v | ||
v += st | ||
i += 1 | ||
end | ||
return i - 1 | ||
return i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, this is still a work in progress to figure out how to do this. The range implementations currently rely on being able to go past the actual end of the supported range, and now that that errors, this needs to be rethought (it doesn't quite work correctly yet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it would help to extend the constructable dates from typemin(Date):typemax(Date)
to the slightly larger set of representable dates typemin(Date)-Day(161):typemax(Date)+Day(280)
const DATETIME_YEAR_TYPEMAX = 146138512 | ||
const DATETIME_YEAR_TYPEMIN = -146138511 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate factoring out these magic numbers.
Check that a constructed
Date
has a year that's within the range of the type's min and max values.Closes #50981