GH-54534: [C++] Fix truncation of sub-minute UTC offsets when formatting and parsing zoned timestamps #54684
All Vouch review confidence checks passed
Residual risk 0.29 = Change Risk (0.49) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.49 · 338 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.349
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #54684"
general
weight: 0.35
ShivanshhhG
Rationale for this change
When formatting zoned timestamps whose UTC offset includes sub-minute seconds (e.g. historical IANA zones such as
Africa/Monroviaprior to 1972 at UTC-00:44:30 orEurope/Parisprior to 1911 at UTC+00:09:21), formatting with%zwould truncate the offset to whole minutes, dropping remaining seconds and causing instant drift. To preserve instant fidelity without violating the%z/%Ezformatting contract (whole minutes±HHMM/±HH:MM), timestamps with sub-minute offsets are formatted in UTC (...Z) during timestamp-to-string cast. Additionally,ParseTimestampISO8601is updated to support parsing 6-digit sub-minute offsets ([+-]HHMMSSand[+-]HH:MM:SS), and%Ezis recognized acrossStrftimeandGetZone.What changes are included in this PR?
1.
cpp/src/arrow/compute/kernels/scalar_cast_string.cc: InConvertZoned, if a timestamp instant has non-zero sub-minute seconds (offset % 60 != 0), format it in UTC (...Z) to preserve the exact stored instant without violating the%zminute contract. Fixed-offset zones (OffsetZone) and UTC take the fast path without redundantget_info()calls.2.
cpp/src/arrow/util/value_parsing.h: Adddetail::ParseHHMMSSand updateParseTimestampISO8601to recognize and parse[+-]HHMMSSand[+-]HH:MM:SSzone offsets.3.
cpp/src/arrow/util/value_parsing.cc&cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc: Unify zone format validation inStrftime::MakeandGetZoneviaFormatHasZoneto recognize%Ezalongside%zand%Z, properly rejecting%Ezwhen the input timestamp has no timezone.4.
cpp/src/arrow/compute/kernels/scalar_cast_test.cc: Add round-trip tests across all four timestamp units (s,ms,us,ns) for historical sub-minute zones (Africa/MonroviaandEurope/Paris), verifying cast to string and back to UTC matches the exact stored value.5.
cpp/src/arrow/compute/kernels/scalar_temporal_test.cc&cpp/src/arrow/util/value_parsing_test.cc: Add unit tests for%Ez(with and without timezones) and sub-minute offset parsing/validation bounds.Are these changes tested?
Yes, covered by unit tests in
scalar_cast_test.cc,scalar_temporal_test.cc, andvalue_parsing_test.cc.Are there any user-facing changes?
...Z), preventing truncation errors and preserving round-trip instant accuracy.[+-]HHMMSSand[+-]HH:MM:SS).strftimenow recognizes%Ezand validates timezone presence identically to%zand%Z.