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

Add chrono 0.4 integration #2612

Merged
merged 29 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
93c6561
Add chrono support
pickfire Aug 31, 2022
76d347a
Make it work with published chrono
Psykopear Sep 1, 2022
b5cdd8e
Added tests from pickfire's branch, fixed Duration to python conversion
Psykopear Sep 9, 2022
851b606
Removed chrono from default features, addded info in features.md
Psykopear Sep 9, 2022
766ac4c
Fixed docstring
Psykopear Sep 9, 2022
58e6748
Removed commented PyTimeZone struct
Psykopear Sep 9, 2022
15b74b2
Fixed clippy issues
Psykopear Sep 9, 2022
4a78a9a
Tests fixes
Psykopear Sep 9, 2022
55ae063
Normalize pydelta, tests refactoring for readability
Psykopear Sep 12, 2022
ba869e3
Update guide/src/features.md
Psykopear Sep 19, 2022
2d81c15
Added example usage and mention in optional features docs
Psykopear Sep 19, 2022
c16903e
Fix docs
Psykopear Sep 19, 2022
3f39bef
Apply suggestions from code review
Psykopear Sep 19, 2022
cac5e48
Fix missing bracket
Psykopear Sep 19, 2022
465fa1f
Applied rustfmt
Psykopear Sep 20, 2022
a514e32
Using C API to convert PyDelta to timezone
Psykopear Sep 20, 2022
e7c0cc0
Added newsfragment, fixed clippy
Psykopear Sep 20, 2022
44269e4
Fixed docs
Psykopear Sep 20, 2022
6187090
Added tests for out of bound values of PyDelta
Psykopear Sep 20, 2022
4d54841
Clippy fix
Psykopear Sep 20, 2022
92c06c0
Fix clippy fix
Psykopear Sep 20, 2022
ba4e522
Added proptests, fixed FixedOffset conversion
Psykopear Sep 20, 2022
585684e
Pinned links to chrono's docs to latest
Psykopear Sep 20, 2022
ee3ee63
Apply suggestions from code review
Psykopear Sep 21, 2022
f42fb65
Moved proptests mod inside tests mod
Psykopear Sep 21, 2022
161d67a
Fix FixedOffset conversion, added NaiveDateTime
Psykopear Sep 21, 2022
cc1ba58
Fail if converting timezone aware to naive
Psykopear Sep 21, 2022
f698219
Clippy fix
Psykopear Sep 21, 2022
032b9d1
Avoid testing zoneinfo on windows
Psykopear Sep 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ inventory = { version = "0.3.0", optional = true }

# crate integrations that can be added using the eponymous features
anyhow = { version = "1.0", optional = true }
chrono = { version = "0.4", optional = true }
eyre = { version = ">= 0.4, < 0.7", optional = true }
hashbrown = { version = ">= 0.9, < 0.13", optional = true }
indexmap = { version = ">= 1.6, < 1.8", optional = true }
Expand All @@ -41,6 +42,7 @@ serde = { version = "1.0", optional = true }

[dev-dependencies]
assert_approx_eq = "1.1.0"
chrono = { version = "0.4" }
criterion = "0.3.5"
trybuild = "1.0.49"
rustversion = "1.0"
Expand Down Expand Up @@ -95,6 +97,7 @@ nightly = []
full = [
"macros",
# "multiple-pymethods", # TODO re-add this when MSRV is greater than 1.62
"chrono",
"num-bigint",
"num-complex",
"hashbrown",
Expand Down Expand Up @@ -163,5 +166,5 @@ members = [

[package.metadata.docs.rs]
no-default-features = true
features = ["macros", "num-bigint", "num-complex", "hashbrown", "serde", "multiple-pymethods", "indexmap", "eyre"]
features = ["macros", "num-bigint", "num-complex", "hashbrown", "serde", "multiple-pymethods", "indexmap", "eyre", "chrono"]
rustdoc-args = ["--cfg", "docsrs"]
10 changes: 10 additions & 0 deletions guide/src/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ These features enable conversions between Python types and types from other Rust

Adds a dependency on [anyhow](https://docs.rs/anyhow). Enables a conversion from [anyhow](https://docs.rs/anyhow)’s [`Error`](https://docs.rs/anyhow/latest/anyhow/struct.Error.html) type to [`PyErr`](https://docs.rs/pyo3/latest/pyo3/struct.PyErr.html), for easy error handling.

### `chrono`
Psykopear marked this conversation as resolved.
Show resolved Hide resolved

Adds a dependency on [chrono](https://docs.rs/chrono). Enables a conversion from [chrono](https://docs.rs/chrono)'s types to python:
- [Duration](https://docs.rs/chrono/latest/chrono/struct.Duration.html) -> [`PyDelta`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDelta.html)
- [FixedOffset](https://docs.rs/chrono/latest/chrono/offset/struct.FixedOffset.html) -> [`PyDelta`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDelta.html)
- [Utc](https://docs.rs/chrono/latest/chrono/offset/struct.Utc.html) -> [`PyTzInfo`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyTzInfo.html)
- [NaiveDate](https://docs.rs/chrono/latest/chrono/naive/struct.NaiveDate.html) -> [`PyDate`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDate.html)
- [NaiveTime](https://docs.rs/chrono/latest/chrono/naive/struct.NaiveTime.html) -> [`PyTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyTime.html)
- [DateTime](https://docs.rs/chrono/latest/chrono/struct.DateTime.html) -> [`PyDateTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDateTime.html)

### `eyre`

Adds a dependency on [eyre](https://docs.rs/eyre). Enables a conversion from [eyre](https://docs.rs/eyre)’s [`Report`](https://docs.rs/eyre/latest/eyre/struct.Report.html) type to [`PyErr`](https://docs.rs/pyo3/latest/pyo3/struct.PyErr.html), for easy error handling.
Expand Down
1 change: 1 addition & 0 deletions newsfragments/2612.packaging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added optional `chrono` feature to convert `chrono` types into types in the `datetime` module.
Loading