Skip to content

Commit

Permalink
Moved jiff support to jiff-01 feature
Browse files Browse the repository at this point in the history
  • Loading branch information
bschoenmaeckers committed Jan 7, 2025
1 parent 1950ec1 commit 312abe8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ either = { version = "1.9", optional = true }
eyre = { version = ">= 0.6.8, < 0.7", optional = true }
hashbrown = { version = ">= 0.14.5, < 0.16", optional = true }
indexmap = { version = ">= 2.5.0, < 3", optional = true }
jiff = { version = "0.1.18", optional = true }
jiff-01 = { package = "jiff", version = "0.1.18", optional = true }
num-bigint = { version = "0.4.2", optional = true }
num-complex = { version = ">= 0.4.6, < 0.5", optional = true }
num-rational = {version = "0.4.1", optional = true }
Expand Down Expand Up @@ -113,6 +113,9 @@ py-clone = []
# Optimizes PyObject to Vec conversion and so on.
nightly = []

_jiff = []
jiff-01 = ["_jiff", "dep:jiff-01"]

# Activates all additional features
# This is mostly intended for testing purposes - activating *all* of these isn't particularly useful.
full = [
Expand Down
4 changes: 3 additions & 1 deletion src/conversions/jiff.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(feature = "jiff")]
#![cfg(feature = "_jiff")]

use crate::exceptions::{PyTypeError, PyValueError};
use crate::pybacked::PyBackedStr;
Expand All @@ -19,6 +19,8 @@ use crate::{intern, Bound, FromPyObject, IntoPyObject, Py, PyAny, PyErr, PyResul
use jiff::civil::{Date, DateTime, Time};
use jiff::tz::{Offset, TimeZone};
use jiff::{SignedDuration, Span, Timestamp, Zoned};
#[cfg(feature = "jiff-01")]
use jiff_01 as jiff;

#[cfg(not(Py_LIMITED_API))]
fn datetime_to_pydatetime<'py>(
Expand Down
4 changes: 2 additions & 2 deletions src/types/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::types::any::PyAnyMethods;
use crate::types::PyTuple;
use crate::{Bound, IntoPyObject, PyAny, PyErr, Python};
use std::os::raw::c_int;
#[cfg(any(feature = "chrono", feature = "jiff"))]
#[cfg(any(feature = "chrono", feature = "_jiff"))]
use std::ptr;

fn ensure_datetime_api(py: Python<'_>) -> PyResult<&'static PyDateTime_CAPI> {
Expand Down Expand Up @@ -698,7 +698,7 @@ pub fn timezone_utc_bound(py: Python<'_>) -> Bound<'_, PyTzInfo> {
/// Equivalent to `datetime.timezone` constructor
///
/// Only used internally
#[cfg(any(feature = "chrono", feature = "jiff"))]
#[cfg(any(feature = "chrono", feature = "_jiff"))]
pub(crate) fn timezone_from_offset<'py>(
offset: &Bound<'py, PyDelta>,
) -> PyResult<Bound<'py, PyTzInfo>> {
Expand Down
2 changes: 1 addition & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ mod code;
pub(crate) mod complex;
#[cfg(not(Py_LIMITED_API))]
pub(crate) mod datetime;
#[cfg(all(Py_LIMITED_API, any(feature = "jiff", feature = "chrono")))]
#[cfg(all(Py_LIMITED_API, any(feature = "chrono", feature = "_jiff")))]
pub(crate) mod datetime_abi;
pub(crate) mod dict;
mod ellipsis;
Expand Down

0 comments on commit 312abe8

Please sign in to comment.