Dates: correct `typemin`/`typemax`, make `Date`, `DateTime`, `Timestamp` overflow-safe #63714
All Vouch review confidence checks passed
Residual risk 0.29 = Change Risk (0.52) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 445 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.365
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #63714"
general
weight: 0.35
PatrickHaecker
typemax(Date)andtypemin(Date)violate the interface inmaster:The same is true for
DateTime.With this PR
typeminandtypemaxreturn the representable extremes, so stepping past them wraps around like integer arithmetic. This required fixing the two limitations behind the old values:year,month,day, ...) overflowed beyond about year ±2.5e14. They now split off whole 400-year cycles and compute on unsigned integers. This makes them correct for everyDateand about 40% faster. Returned months and days are now alwaysInt64, as documented.Daynow behave like integer ranges and no longer throw anOverflowErrorwhen their endpoints are far apart.lengthwraps andchecked_lengththrows.MonthandYearsteps are counted exactly, which also covers the overshoot targeted by #64598, including negative steps.Once the extremes are reachable, every operation near them has to be correct, so this PR also fixes the overflows found there:
Date(y, m, d)andDateTime(...)throw anArgumentErrorfor dates outside the type instead of wrapping around.DateTime(::Date),unix2datetime,julian2datetime, andrata2datetimethrow anInexactErrorinstead of wrapping around.floor,ceil,round,trunc, and thefirstdayof…/lastdayof…adjusters throw anOverflowErrorwhen the result lies outside the type. This holds forDate,DateTime, andTimestamp.Microsecond(1500)compute each element from the start, so iteration,length, indexing, andinagree and no longer come out empty or hang.Performance
The checks stay on 64-bit paths for built-in periods and widen only near the ends of the type or for huge periods. Besides the accessors:
isoweekdatetakes about a third less time.trunctoHour,Minute, orSecondtakes about half the time.MonthorQuartertakes about 10% less time.Timestamprounding to a whole-tick period takes about a third less time.unix2timestamp(::Rational)is much faster.Known limitations
TimeType + Periodarithmetic still wraps around at the ends of the type, likeInt64(#50930 is orthogonal).-
lengthof a range with more thantypemax(Int)elements wraps around.- An empty slice cannot start at an end of the type and throws an
OverflowError.- A
typeminperiod step negates to itself.reverseof calendar or fractional-step ranges restart at the slice's first element, so later elements can differ fromr[s](documented).Timestampcases throw anInexactError:- steps that do not fit in the tick period;
-
Timestamp + Monthwith wide-second ticks;- wide calendar ranges whose step count exceeds
Int64.TimeTypes without aguessmethod cannot compute the length of non-fixed-step ranges.Fixes: #41082, #50931, #50981
Supersedes: #54933
I recommend reviewing commit-by-commit.
Prepared with GitHub Copilot (Claude Opus 5.5).