ShivanshhhG opened a new pull request, #54684:
URL: https://github.com/apache/arrow/pull/54684

   ### Rationale for this change
   
   When formatting zoned timestamps whose UTC offset includes sub-minute 
seconds (e.g. historical IANA zones such as `Africa/Monrovia` prior to 1972 at 
UTC-00:44:30 or `Europe/Paris` prior to 1911 at UTC+00:09:21), the vendored 
`date.h` library truncated the offset to whole minutes via 
`duration_cast<minutes>`, dropping the remaining seconds and emitting an 
inaccurate offset (e.g. `-0044` instead of `-004430`). When parsed back (via 
`Cast` or CSV reader), the timestamp instant was shifted by up to 59 seconds.
   
   ### What changes are included in this PR?
   
   1. `cpp/src/arrow/vendored/datetime/date.h`: In `to_stream` for `%z` and 
`%Ez`, check whether `*offset_sec` has non-zero seconds (`s != 0`). If present, 
format the seconds component (`±hhmmss` for `%z`, `±hh:mm:ss` for `%Ez`). If 
whole minutes, preserve the standard `±hhmm` / `±hh:mm` representation.
   2. `cpp/src/arrow/util/value_parsing.h`: Add `detail::ParseHHMMSS` to parse 
6-digit offsets and update `ParseTimestampISO8601` to recognize and parse 
`[+-]HHMMSS` and `[+-]HH:MM:SS` zone offsets.
   3. `cpp/src/arrow/util/value_parsing.cc` & 
`cpp/src/arrow/compute/kernels/scalar_temporal_unary.cc`: Recognize `%Ez` as 
providing a zone offset in `StrptimeTimestampParser` and `GetZone`.
   4. `cpp/src/arrow/util/value_parsing_test.cc`: Add unit tests for sub-minute 
offsets (`+004430`, `+00:44:30`, `-004430`, `-00:44:30`) and invalid offset 
validations (`+00:00:60`, `+000060`, `+240000`, `+24:00:00`).
   5. `cpp/src/arrow/compute/kernels/scalar_cast_test.cc`: Add regression tests 
casting zoned timestamps in `Africa/Monrovia` (-00:44:30) and `Europe/Paris` 
(+00:09:21) to string arrays.
   
   ### Are these changes tested?
   
   Yes, verified with standalone compilation and unit tests covering parsing, 
formatting, validation bounds, and cast kernels.
   
   ### Are there any user-facing changes?
   
   Formatting zoned timestamps with historical sub-minute UTC offsets now 
accurately emits the seconds component (`±HH:MM:SS` or `±HHMMSS`) rather than 
truncating them to minutes, preserving instant fidelity across round-trips.
   
   * GitHub Issue: #54534


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to