Skip to content
Closed
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
22 changes: 13 additions & 9 deletions src/input/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ 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::{DateTimeConfig, MicrosecondsPrecisionOverflowBehavior};
use std::borrow::Cow;
use std::collections::hash_map::DefaultHasher;
use std::fmt::Write;
Expand Down Expand Up @@ -366,10 +366,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::builder()
.time_config(TimeConfig {
microseconds_precision_overflow_behavior: microseconds_overflow_behavior,
unix_timestamp_offset: Some(0),
})
.build(),
) {
Ok(dt) => Ok(dt.into()),
Err(err) => Err(ValError::new(
Expand All @@ -390,10 +392,12 @@ pub fn int_as_datetime<'py>(
match DateTime::from_timestamp_with_config(
timestamp,
timestamp_microseconds,
&TimeConfig {
unix_timestamp_offset: Some(0),
..Default::default()
},
&DateTimeConfig::builder()
.time_config(TimeConfig {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ Feel like we should use the builder here, but just left as is for now to make this a simple update

unix_timestamp_offset: Some(0),
..Default::default()
})
.build(),
) {
Ok(dt) => Ok(dt.into()),
Err(err) => Err(ValError::new(
Expand Down
3 changes: 2 additions & 1 deletion src/validators/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use pyo3::sync::GILOnceCell;
use pyo3::types::{PyDict, PyString};
use speedate::{DateTime, MicrosecondsPrecisionOverflowBehavior, Time};
use std::cmp::Ordering;
use std::str::FromStr;
use strum::EnumMessage;

use crate::build_tools::{is_strict, py_schema_error_type};
Expand Down Expand Up @@ -32,7 +33,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>| speedate::MicrosecondsPrecisionOverflowBehavior::from_str(v.to_str().unwrap()),
)
.map_err(|_| {
py_schema_error_type!("Invalid `microseconds_precision`, must be one of \"truncate\" or \"error\"")
Expand Down
Loading