Add date.toordinal(), date.fromordinal(), datetime.toordinal(), and datetime.fromordinal() #1271
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 363 lines diff across 4 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.353
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1271"
general
weight: 0.35
davidhewitt
Implement proleptic Gregorian day ordinal methods on
dateanddatetimematching CPython 3.14 semantics.Changes
FromordinalandToordinalvariants toStaticStrings.ord_to_yearindate.rsto compute Gregorian years for ordinals above3,652,059, matching CPython'sValueError: year must be in 1..9999, not {year}error format.date_from_ordinalandclass_fromordinalonDate, parsing arguments viaFromOrdinalArgswithstyle = parse_tupleto reject keywords (TypeError: fromordinal() takes no keyword arguments) and check arity (TypeError: fromordinal() takes exactly 1 argument (N given)).date.toordinal()anddate.fromordinal(), accessible on both class and instance.datetime.toordinal()anddatetime.fromordinal(), returning a naivedatetimeat midnight (00:00:00).Type::call_attrforDateandDateTime.docs/limitations/datetime.mdto reflecttoordinalandfromordinal()support.crates/monty/test_cases/datetime__core.pycovering boundary ordinals (Day 10001-01-01, Day 3,652,0599999-12-31), leap years, epoch dates, instance invocations,__index__coercion,ValueErrormessage parity, integer overflow checks (i32bounds and BigInt), arity checks, and kwarg rejection.Validation
cargo run -p monty-datatest -j 2 -- datetime__(14/14 tests passed on both Monty and CPython).cargo test -p monty -j 2 --test datetime_format(9/9 tests passed).cargo clippy -p monty -j 2 --all-targets -- -D warnings(passed with zero warnings).cargo +nightly fmt --all(passed).<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Adds
toordinal()andfromordinal()todateanddatetime, matching CPython 3.14 semantics, now built on Jiff primitives after the chrono migration.fromordinal(ordinal)constructs a date or a naive datetime at midnight;toordinal()returns the day count since0001-01-01.__index__coercion match CPython.<sup>Written for commit 7a37259904c479bab795cc7484d3570f0a4ac3c7. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/1271?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->