Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Python 3.7 timezone in datetime bindings #207

Closed
pganssle opened this issue Aug 22, 2018 · 4 comments · Fixed by #1588
Closed

Support Python 3.7 timezone in datetime bindings #207

pganssle opened this issue Aug 22, 2018 · 4 comments · Fixed by #1588

Comments

@pganssle
Copy link
Member

pganssle commented Aug 22, 2018

As part of #200 (which added the Python datetime bindings), the update for the full Python 3.7 interface, which includes:

The timezone API was added to CPython in PR 5032.

I believe this can be accompanied on the Rust side by a PyFixedTimeZone object or something. It's worth noting that no _Check methods accompany this, because you are really not intended to subclass these things.

@pickfire
Copy link
Contributor

pickfire commented Apr 15, 2021

Can I get some pointers on how to provide a wrapper for PyDateTime_TimeZone_UTC?

I see that we can do PyObject::from_borrowed_ptr(py, PyDateTimeAPI.TimeZone_UTC) but should we do it the same way as python::NotImplemented()? I wonder how should we handle the singleton in this case?

Also, how can one do <PyXXXUTC as PyTryFrom>::try_from(ob) when implementing FromPyObject for chrono::Utc? I don't get how do we PyTryFrom a thing that does not have a thin wrapper, even if we have, I am still confused if we can use pyobject_native_type! for this?

Context https://github.com/chronotope/chrono/pull/542/files#diff-70ff3919bf785b8ecc0ce5229161d04c1525d549664aa48e30d3415feffb2eb3R125

@davidhewitt
Copy link
Member

@pickfire I'm thinking about the correct design for this; please allow me a few days.

@pickfire
Copy link
Contributor

pickfire commented Apr 17, 2021

Just discussing, I will only get to use FromOffset (which correlates to chrono FixedOffset) and UTC (which correlates to chrono Utc), so minimally I require those two, but while doing that I can probably add the FixedOffsetWithName as well.

I believe I can just start with PyTimeZone_FromOffset since that is straightforward. Maybe I will keep UTC for later.

@davidhewitt
Copy link
Member

@pickfire maybe #1573 gets you started? With that PR you could do ffi::PyDateTime_TimeZone_UTC.as_ref(py) to get a &PyAny representing the singleton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants