diff --git a/bindings/nodejs/Cargo.toml b/bindings/nodejs/Cargo.toml index 0ca51d488..de39ad313 100644 --- a/bindings/nodejs/Cargo.toml +++ b/bindings/nodejs/Cargo.toml @@ -15,7 +15,7 @@ doc = false [dependencies] databend-driver = { workspace = true, features = ["rustls", "flight-sql"] } -chrono = { version = "0.4", default-features = false } +chrono = { version = "0.4.35", default-features = false } napi = { version = "2.14", default-features = false, features = [ "napi6", "async", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 64e2b7277..4d42879d6 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -15,7 +15,7 @@ databend-driver = { workspace = true, features = ["rustls", "flight-sql"] } anyhow = "1.0" async-trait = "0.1" -chrono = { version = "0.4.31", default-features = false, features = ["clock"] } +chrono = { version = "0.4.35", default-features = false, features = ["clock"] } clap = { version = "4.4", features = ["derive", "env"] } comfy-table = "7.1" csv = "1.3" diff --git a/core/Cargo.toml b/core/Cargo.toml index 8e978ad67..12752a68b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -34,4 +34,4 @@ url = { version = "2.5", default-features = false } uuid = { version = "1.6", features = ["v4"] } [dev-dependencies] -chrono = { version = "0.4", default-features = false, features = ["clock"] } +chrono = { version = "0.4.35", default-features = false, features = ["clock"] } diff --git a/driver/Cargo.toml b/driver/Cargo.toml index 2c48fe13e..8b029b380 100644 --- a/driver/Cargo.toml +++ b/driver/Cargo.toml @@ -31,7 +31,7 @@ databend-driver-macros = { workspace = true } databend-sql = { workspace = true } async-trait = "0.1" -chrono = { version = "0.4.31", default-features = false, features = ["clock"] } +chrono = { version = "0.4.35", default-features = false, features = ["clock"] } csv = "1.3" dyn-clone = "1.0" glob = "0.3" diff --git a/sql/Cargo.toml b/sql/Cargo.toml index a8d932851..304e4afac 100644 --- a/sql/Cargo.toml +++ b/sql/Cargo.toml @@ -16,7 +16,7 @@ flight-sql = ["dep:arrow-array", "dep:arrow-schema", "dep:tonic"] [dependencies] databend-client = { workspace = true } -chrono = { version = "0.4", default-features = false } +chrono = { version = "0.4.35", default-features = false } geozero = { version = "0.12.0", features = ["default", "with-wkb"] } glob = "0.3" itertools = "0.12" diff --git a/sql/src/value.rs b/sql/src/value.rs index 741705d12..7f8ea27e5 100644 --- a/sql/src/value.rs +++ b/sql/src/value.rs @@ -13,7 +13,7 @@ // limitations under the License. use arrow::datatypes::{i256, ArrowNativeTypeOp}; -use chrono::{Datelike, NaiveDate, NaiveDateTime}; +use chrono::{DateTime, Datelike, NaiveDate, NaiveDateTime}; use crate::{ error::{ConvertError, Error, Result}, @@ -189,6 +189,7 @@ impl TryFrom<(&DataType, &str)> for Value { DataType::Timestamp => Ok(Self::Timestamp( chrono::NaiveDateTime::parse_from_str(v, "%Y-%m-%d %H:%M:%S%.6f")? + .and_utc() .timestamp_micros(), )), DataType::Date => Ok(Self::Date( @@ -525,9 +526,9 @@ impl TryFrom for NaiveDateTime { Value::Timestamp(i) => { let secs = i / 1_000_000; let nanos = ((i % 1_000_000) * 1000) as u32; - let t = NaiveDateTime::from_timestamp_opt(secs, nanos); + let t = DateTime::from_timestamp(secs, nanos); match t { - Some(t) => Ok(t), + Some(t) => Ok(t.naive_utc()), None => Err(ConvertError::new("NaiveDateTime", "".to_string()).into()), } } @@ -633,7 +634,8 @@ fn encode_value(f: &mut std::fmt::Formatter<'_>, val: &Value, raw: bool) -> std: Value::Timestamp(i) => { let secs = i / 1_000_000; let nanos = ((i % 1_000_000) * 1000) as u32; - let t = NaiveDateTime::from_timestamp_opt(secs, nanos).unwrap_or_default(); + let t = DateTime::from_timestamp(secs, nanos).unwrap_or_default(); + let t = t.naive_utc(); if raw { write!(f, "{}", t) } else {