MarcoGorelli commented on issue #15047:
URL: https://github.com/apache/arrow/issues/15047#issuecomment-1594706777
thanks for looking into this so deeply!
sure but the zoneinfo one still looks more correct? e.g. in the UK the DST
transition happens on the last Sunday of October and of March, and
(unfortunately) hasn't announced that they intend to change this. zoneinfo
seems to extrapolate that correctly beyond 2038:
```python
In [29]:
...: string = '2058-10-28 00:00:00.000000'
...:
...: dt = datetime.fromisoformat(string)
...: dt = dt.replace(tzinfo=ZoneInfo('Europe/London'))
...: tz = ZoneInfo('UTC')
...: converted_dt = dt.astimezone(tz)
...: print(converted_dt)
2058-10-28 00:00:00+00:00
In [30]:
...: string = '2058-10-27 00:00:00.000000'
...:
...: dt = datetime.fromisoformat(string)
...: dt = dt.replace(tzinfo=ZoneInfo('Europe/London'))
...: tz = ZoneInfo('UTC')
...: converted_dt = dt.astimezone(tz)
...: print(converted_dt)
2058-10-26 23:00:00+00:00
In [31]: dt.strftime('%a')
Out[31]: 'Sun'
```
For reference, same with chrono-tz (haven't looked into how, but this is
just to say - the fact `chrono-tz` extrapolates forwards differently to `arrow`
explains the discrepancy when converting polars to pyarrow (or to pandas))
```Rust
use chrono::{NaiveDateTime, TimeZone};
use chrono_tz::Tz;
fn main() {
let dt = NaiveDateTime::parse_from_str("2058-10-28 00:00:00", "%Y-%m-%d
%H:%M:%S").unwrap();
let tz = Tz::Europe__London;
let dt = tz.from_local_datetime(&dt).unwrap();
println!("converted: {:?}", dt);
let dt = NaiveDateTime::parse_from_str("2058-10-27 00:00:00", "%Y-%m-%d
%H:%M:%S").unwrap();
let tz = Tz::Europe__London;
let dt = tz.from_local_datetime(&dt).unwrap();
println!("converted: {:?}", dt);
}
```
outputs
```
converted: 2058-10-28T00:00:00GMT
converted: 2058-10-27T00:00:00BST
```
--
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]