Skip to content

Commit f3d3245

Browse files
Update jiff to v0.2 (#4903)
* Update jiff to v0.2 * Update (hopefully) all urls in features.md
1 parent 4f1af4d commit f3d3245

File tree

7 files changed

+33
-31
lines changed

7 files changed

+33
-31
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ jobs:
460460
- uses: dtolnay/rust-toolchain@nightly
461461
with:
462462
components: rust-src
463-
- run: cargo rustdoc --lib --no-default-features --features full,jiff-01 -Zunstable-options --config "build.rustdocflags=[\"--cfg\", \"docsrs\"]"
463+
- run: cargo rustdoc --lib --no-default-features --features full,jiff-02 -Zunstable-options --config "build.rustdocflags=[\"--cfg\", \"docsrs\"]"
464464

465465
coverage:
466466
if: ${{ github.event_name != 'merge_group' }}

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ either = { version = "1.9", optional = true }
3939
eyre = { version = ">= 0.6.8, < 0.7", optional = true }
4040
hashbrown = { version = ">= 0.14.5, < 0.16", optional = true }
4141
indexmap = { version = ">= 2.5.0, < 3", optional = true }
42-
jiff-01 = { package = "jiff", version = "0.1.18", optional = true }
42+
jiff-02 = { package = "jiff", version = "0.2", optional = true }
4343
num-bigint = { version = "0.4.2", optional = true }
4444
num-complex = { version = ">= 0.4.6, < 0.5", optional = true }
4545
num-rational = {version = "0.4.1", optional = true }

guide/src/features.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,17 @@ Adds a dependency on [hashbrown](https://docs.rs/hashbrown) and enables conversi
151151

152152
Adds a dependency on [indexmap](https://docs.rs/indexmap) and enables conversions into its [`IndexMap`](https://docs.rs/indexmap/latest/indexmap/map/struct.IndexMap.html) type.
153153

154-
### `jiff-01`
155-
156-
Adds a dependency on [jiff@0.1](https://docs.rs/jiff/0.1) and requires MSRV 1.70. Enables a conversion from [jiff](https://docs.rs/jiff)'s types to python:
157-
- [SignedDuration](https://docs.rs/jiff/0.1/jiff/struct.SignedDuration.html) -> [`PyDelta`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDelta.html)
158-
- [TimeZone](https://docs.rs/jiff/0.1/jiff/tz/struct.TimeZone.html) -> [`PyTzInfo`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyTzInfo.html)
159-
- [Offset](https://docs.rs/jiff/0.1/jiff/tz/struct.Offset.html) -> [`PyTzInfo`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyTzInfo.html)
160-
- [Date](https://docs.rs/jiff/0.1/jiff/civil/struct.Date.html) -> [`PyDate`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDate.html)
161-
- [Time](https://docs.rs/jiff/0.1/jiff/civil/struct.Time.html) -> [`PyTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyTime.html)
162-
- [DateTime](https://docs.rs/jiff/0.1/jiff/civil/struct.DateTime.html) -> [`PyDateTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDateTime.html)
163-
- [Zoned](https://docs.rs/jiff/0.1/jiff/struct.Zoned.html) -> [`PyDateTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDateTime.html)
164-
- [Timestamp](https://docs.rs/jiff/0.1/jiff/struct.Timestamp.html) -> [`PyDateTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDateTime.html)
154+
### `jiff-02`
155+
156+
Adds a dependency on [jiff@0.2](https://docs.rs/jiff/0.2) and requires MSRV 1.70. Enables a conversion from [jiff](https://docs.rs/jiff)'s types to python:
157+
- [SignedDuration](https://docs.rs/jiff/0.2/jiff/struct.SignedDuration.html) -> [`PyDelta`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDelta.html)
158+
- [TimeZone](https://docs.rs/jiff/0.2/jiff/tz/struct.TimeZone.html) -> [`PyTzInfo`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyTzInfo.html)
159+
- [Offset](https://docs.rs/jiff/0.2/jiff/tz/struct.Offset.html) -> [`PyTzInfo`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyTzInfo.html)
160+
- [Date](https://docs.rs/jiff/0.2/jiff/civil/struct.Date.html) -> [`PyDate`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDate.html)
161+
- [Time](https://docs.rs/jiff/0.2/jiff/civil/struct.Time.html) -> [`PyTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyTime.html)
162+
- [DateTime](https://docs.rs/jiff/0.2/jiff/civil/struct.DateTime.html) -> [`PyDateTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDateTime.html)
163+
- [Zoned](https://docs.rs/jiff/0.2/jiff/struct.Zoned.html) -> [`PyDateTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDateTime.html)
164+
- [Timestamp](https://docs.rs/jiff/0.2/jiff/struct.Timestamp.html) -> [`PyDateTime`]({{#PYO3_DOCS_URL}}/pyo3/types/struct.PyDateTime.html)
165165

166166
### `num-bigint`
167167

noxfile.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def test_rust(session: nox.Session):
6565
if not FREE_THREADED_BUILD:
6666
_run_cargo_test(session, features="abi3")
6767
if "skip-full" not in session.posargs:
68-
_run_cargo_test(session, features="full jiff-01")
68+
_run_cargo_test(session, features="full jiff-02")
6969
if not FREE_THREADED_BUILD:
70-
_run_cargo_test(session, features="abi3 full jiff-01")
70+
_run_cargo_test(session, features="abi3 full jiff-02")
7171

7272

7373
@nox.session(name="test-py", venv_backend="none")
@@ -395,7 +395,7 @@ def docs(session: nox.Session) -> None:
395395

396396
if get_rust_version()[:2] >= (1, 70):
397397
# jiff needs MSRC 1.70+
398-
features += ",jiff-01"
398+
features += ",jiff-02"
399399

400400
shutil.rmtree(PYO3_DOCS_TARGET, ignore_errors=True)
401401
_run_cargo(
@@ -777,8 +777,8 @@ def update_ui_tests(session: nox.Session):
777777
env["TRYBUILD"] = "overwrite"
778778
command = ["test", "--test", "test_compile_error"]
779779
_run_cargo(session, *command, env=env)
780-
_run_cargo(session, *command, "--features=full,jiff-01", env=env)
781-
_run_cargo(session, *command, "--features=abi3,full,jiff-01", env=env)
780+
_run_cargo(session, *command, "--features=full,jiff-02", env=env)
781+
_run_cargo(session, *command, "--features=abi3,full,jiff-02", env=env)
782782

783783

784784
def _build_docs_for_ffi_check(session: nox.Session) -> None:
@@ -831,7 +831,7 @@ def _get_feature_sets() -> Generator[Tuple[str, ...], None, None]:
831831

832832
if get_rust_version()[:2] >= (1, 70):
833833
# jiff needs MSRC 1.70+
834-
features += ",jiff-01"
834+
features += ",jiff-02"
835835

836836
yield (f"--features={features}",)
837837
yield (f"--features=abi3,{features}",)

src/conversions/jiff.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(feature = "jiff-01")]
1+
#![cfg(feature = "jiff-02")]
22

33
//! Conversions to and from [jiff](https://docs.rs/jiff/)’s `Span`, `SignedDuration`, `TimeZone`,
44
//! `Offset`, `Date`, `Time`, `DateTime`, `Zoned`, and `Timestamp`.
@@ -9,8 +9,8 @@
99
//!
1010
//! ```toml
1111
//! [dependencies]
12-
//! jiff = "0.1"
13-
#![doc = concat!("pyo3 = { version = \"", env!("CARGO_PKG_VERSION"), "\", features = [\"jiff-01\"] }")]
12+
//! jiff = "0.2"
13+
#![doc = concat!("pyo3 = { version = \"", env!("CARGO_PKG_VERSION"), "\", features = [\"jiff-02\"] }")]
1414
//! ```
1515
//!
1616
//! Note that you must use compatible versions of jiff and PyO3.
@@ -21,7 +21,7 @@
2121
//!
2222
//! ```rust
2323
//! # #![cfg_attr(windows, allow(unused_imports))]
24-
//! # use jiff_01 as jiff;
24+
//! # use jiff_02 as jiff;
2525
//! use jiff::{Zoned, SignedDuration, ToSpan};
2626
//! use pyo3::{Python, PyResult, IntoPyObject, types::PyAnyMethods};
2727
//!
@@ -65,8 +65,8 @@ use crate::{intern, Bound, FromPyObject, IntoPyObject, Py, PyAny, PyErr, PyResul
6565
use jiff::civil::{Date, DateTime, Time};
6666
use jiff::tz::{Offset, TimeZone};
6767
use jiff::{SignedDuration, Span, Timestamp, Zoned};
68-
#[cfg(feature = "jiff-01")]
69-
use jiff_01 as jiff;
68+
#[cfg(feature = "jiff-02")]
69+
use jiff_02 as jiff;
7070

7171
#[cfg(not(Py_LIMITED_API))]
7272
fn datetime_to_pydatetime<'py>(
@@ -1120,6 +1120,7 @@ mod tests {
11201120
use super::*;
11211121
use crate::types::IntoPyDict;
11221122
use jiff::tz::TimeZoneTransition;
1123+
use jiff::SpanRelativeTo;
11231124
use proptest::prelude::*;
11241125
use std::ffi::CString;
11251126

@@ -1191,10 +1192,11 @@ mod tests {
11911192
// python values of durations (from -999999999 to 999999999 days),
11921193
Python::with_gil(|py| {
11931194
if let Ok(span) = Span::new().try_days(days) {
1194-
let date = Date::new(2025, 1, 1).unwrap();
1195-
let py_delta = span.to_jiff_duration(date).unwrap().into_pyobject(py).unwrap();
1195+
let relative_to = SpanRelativeTo::days_are_24_hours();
1196+
let jiff_duration = span.to_duration(relative_to).unwrap();
1197+
let py_delta = jiff_duration.into_pyobject(py).unwrap();
11961198
let roundtripped: Span = py_delta.extract().expect("Round trip");
1197-
assert_eq!(span.compare(roundtripped).unwrap(), Ordering::Equal);
1199+
assert_eq!(span.compare((roundtripped, relative_to)).unwrap(), Ordering::Equal);
11981200
}
11991201
})
12001202
}

src/types/datetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::types::any::PyAnyMethods;
2727
use crate::types::PyTuple;
2828
use crate::{Bound, IntoPyObject, PyAny, PyErr, Python};
2929
use std::os::raw::c_int;
30-
#[cfg(any(feature = "chrono", feature = "jiff-01"))]
30+
#[cfg(any(feature = "chrono", feature = "jiff-02"))]
3131
use std::ptr;
3232

3333
fn ensure_datetime_api(py: Python<'_>) -> PyResult<&'static PyDateTime_CAPI> {
@@ -698,7 +698,7 @@ pub fn timezone_utc_bound(py: Python<'_>) -> Bound<'_, PyTzInfo> {
698698
/// Equivalent to `datetime.timezone` constructor
699699
///
700700
/// Only used internally
701-
#[cfg(any(feature = "chrono", feature = "jiff-01"))]
701+
#[cfg(any(feature = "chrono", feature = "jiff-02"))]
702702
pub(crate) fn timezone_from_offset<'py>(
703703
offset: &Bound<'py, PyDelta>,
704704
) -> PyResult<Bound<'py, PyTzInfo>> {

src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ mod code;
239239
pub(crate) mod complex;
240240
#[cfg(not(Py_LIMITED_API))]
241241
pub(crate) mod datetime;
242-
#[cfg(all(Py_LIMITED_API, any(feature = "chrono", feature = "jiff-01")))]
242+
#[cfg(all(Py_LIMITED_API, any(feature = "chrono", feature = "jiff-02")))]
243243
pub(crate) mod datetime_abi3;
244244
pub(crate) mod dict;
245245
mod ellipsis;

0 commit comments

Comments
 (0)