-
Notifications
You must be signed in to change notification settings - Fork 826
Impl time crate into pyo3 #5057
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
Conversation
There is no implementation for UtcDateTime. Is that a oversight? |
I provided an implementation in earlier commits but I realized that the https://github.com/time-rs/time/blob/v0.3.41/time-core/Cargo.toml I duno if breaking msrv is a good idea so I decided to downgrade time crate back to Should I just bump the msrv and bring back |
It is OK to break the msrv in a optional feature. The jiff integration currently does the same thing (see #4823). Just make sure it is documented properly. Further more forcing the time dependency to a fixed version is probably too invasive for users to be usable. So setting the minimum version to |
Please document the new feature in the guide as well; https://pyo3.rs/latest/features.html. |
looks like main is broken ? @davidhewitt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! #5065 should have unblocked CI.
Similar to the addition of jiff
you have to add the time
feature in the noxfile so that the tests run in CI (because it can't be in full
for MSRV reasons)
src/conversions/time.rs
Outdated
// // Get UTC timezone | ||
// #[cfg(not(Py_LIMITED_API))] | ||
// let py_tzinfo = py | ||
// .import("datetime")? | ||
// .getattr(intern!(py, "timezone"))? | ||
// .getattr(intern!(py, "utc"))?; | ||
// | ||
// #[cfg(Py_LIMITED_API)] | ||
let py_tzinfo = py | ||
.import("datetime")? | ||
.getattr(intern!(py, "timezone"))? | ||
.getattr(intern!(py, "utc"))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can should use the utc_timezone
function. https://pyo3.rs/main/doc/pyo3/types/fn.timezone_utc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've switched to use timezone_utc
function
src/conversions/time.rs
Outdated
let is_utc = tzinfo | ||
.call_method1( | ||
"__eq__", | ||
(ob.py() | ||
.import("datetime")? | ||
.getattr(intern!(ob.py(), "timezone"))? | ||
.getattr(intern!(ob.py(), "utc"))?,), | ||
)? | ||
.extract::<bool>()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let is_utc = tzinfo | |
.call_method1( | |
"__eq__", | |
(ob.py() | |
.import("datetime")? | |
.getattr(intern!(ob.py(), "timezone"))? | |
.getattr(intern!(ob.py(), "utc"))?,), | |
)? | |
.extract::<bool>()?; | |
let is_utc = tzinfo.eq(timezone_utc(py))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks & changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! Thanks again 🚀
FIxes #4675
This MR integrates time crate into PyO3 ecosystem. It implements
FromPyObject
andIntoPyObject
for the following structs from time crate: