spicysharkco opened a new pull request, #11702:
URL: https://github.com/apache/arrow-rs/pull/11702
# Which issue does this PR close?
- Closes #11698
# Rationale for this change
An RFC 3339 offset has no seconds, so chrono rounds one that is not a whole
number of minutes, and the text names a different instant:
```rust
let array =
TimestampMillisecondArray::from(vec![-302443199750]).with_timezone("Africa/Monrovia");
// formatted with the default `FormatOptions`:
// 1960-06-01T11:15:30.250-00:45
```
The stored instant is `1960-06-01T12:00:00.250Z`, so the text is 30 seconds
later. Africa/Monrovia was 44 minutes 30 seconds behind UTC until 1972, and
most zones' local mean time is affected too. The CSV and JSON writers and casts
to a string type format through
[`write_timestamp`](https://github.com/apache/arrow-rs/blob/3327fbef1c3381a149e9a413a5bb22813e11639e/arrow-cast/src/display.rs#L770),
so a reader gets a different instant with no error.
# What changes are included in this PR?
With the default format, when the offset at that instant is not a whole
number of minutes, `write_timestamp` writes the instant in UTC (`...Z`). That
is exact, and `string_to_datetime` reads it back; it rejects an offset with
seconds. Whole-minute offsets and custom formats are unchanged. The `Debug`
output of a timestamp array rounds the same way and is left as is.
# Are these changes tested?
Yes, `display::tests::test_timestamp_tz_offset_with_seconds`. It formats
Africa/Monrovia (1960) and Europe/Paris (1900), reads the text back to the same
instant, and checks that `+05:30` is still written as an offset. It fails on
`main`.
# Are there any significant user-facing changes?
The text for such an instant now ends in `Z` instead of a rounded offset.
--
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]