Skip to content

update to speedate 0.16 #1740

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

Merged
merged 1 commit into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 7 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ rust-version = "1.75"
# but needs a bit of work to make sure it's not used in the codebase
pyo3 = { version = "0.25", features = ["generate-import-lib", "num-bigint", "py-clone"] }
regex = "1.11.1"
strum = { version = "0.26.3", features = ["derive"] }
strum_macros = "0.26.4"
strum = { version = "0.27", features = ["derive"] }
strum_macros = "0.27"
serde_json = { version = "1.0.140", features = ["arbitrary_precision"] }
enum_dispatch = "0.3.13"
serde = { version = "1.0.219", features = ["derive"] }
speedate = "0.15.0"
speedate = "0.16.0"
smallvec = "1.15.0"
ahash = "0.8.12"
url = "2.5.4"
Expand Down
21 changes: 14 additions & 7 deletions src/input/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use pyo3::pyclass::CompareOp;
use pyo3::types::PyTuple;
use pyo3::types::{PyDate, PyDateTime, PyDelta, PyDeltaAccess, PyDict, PyTime, PyTzInfo};
use pyo3::IntoPyObjectExt;
use speedate::MicrosecondsPrecisionOverflowBehavior;
use speedate::{Date, DateTime, Duration, ParseError, Time, TimeConfig};
use speedate::{
Date, DateTime, DateTimeConfig, Duration, MicrosecondsPrecisionOverflowBehavior, ParseError, Time, TimeConfig,
};
use std::borrow::Cow;
use std::collections::hash_map::DefaultHasher;
use std::fmt::Write;
Expand Down Expand Up @@ -366,9 +367,12 @@ pub fn bytes_as_datetime<'py>(
) -> ValResult<EitherDateTime<'py>> {
match DateTime::parse_bytes_with_config(
bytes,
&TimeConfig {
microseconds_precision_overflow_behavior: microseconds_overflow_behavior,
unix_timestamp_offset: Some(0),
&DateTimeConfig {
time_config: TimeConfig {
microseconds_precision_overflow_behavior: microseconds_overflow_behavior,
unix_timestamp_offset: Some(0),
},
..Default::default()
},
) {
Ok(dt) => Ok(dt.into()),
Expand All @@ -390,8 +394,11 @@ pub fn int_as_datetime<'py>(
match DateTime::from_timestamp_with_config(
timestamp,
timestamp_microseconds,
&TimeConfig {
unix_timestamp_offset: Some(0),
&DateTimeConfig {
time_config: TimeConfig {
unix_timestamp_offset: Some(0),
..Default::default()
},
..Default::default()
},
) {
Expand Down
2 changes: 1 addition & 1 deletion src/validators/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) fn extract_microseconds_precision(
schema_or_config_same(schema, config, intern!(schema.py(), "microseconds_precision"))?
.map_or(
Ok(speedate::MicrosecondsPrecisionOverflowBehavior::Truncate),
|v: Bound<'_, PyString>| speedate::MicrosecondsPrecisionOverflowBehavior::try_from(v.to_str().unwrap()),
|v: Bound<'_, PyString>| v.to_str().unwrap().parse(),
)
.map_err(|_| {
py_schema_error_type!("Invalid `microseconds_precision`, must be one of \"truncate\" or \"error\"")
Expand Down
Loading