Skip to content

Make TzInner public #7173

@kylebarron

Description

@kylebarron

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

In pyo3-arrow, I'm converting from Arrow scalars to Python objects.

Prior to pyo3 0.23.4, pyo3 handled the object conversion by converting all time zones to a fixed offset, but as of pyo3 0.23.4, pyo3 requires the Tz implementation to implement IntoPyObject, and arrow_array::timezone::Tz does not.

One way to fix this is to converting all time zones to a fixed offset manually, e.g.

let dt: chrono::DateTime<arrow_array::timezone::Tz> = ...;
dt.fixed_offset().into_py_any(py)?

But this loses timezone information. It would be ideal to convert all timezone information into the Python scalar. But TzInner is private:

#[derive(Debug, Copy, Clone)]
enum TzInner {
Timezone(chrono_tz::Tz),
Offset(FixedOffset),
}

So we have no way to access the underlying chrono_tz::Tz out of the Tz.

Describe the solution you'd like

Make TzInner public.

Describe alternatives you've considered

Always convert to a fixed offset, but this will lose any timezone information.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAny new improvement worthy of a entry in the changelog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions