Skip to content

Commit

Permalink
fix: fix chrono version (#362)
Browse files Browse the repository at this point in the history
* update

* update

* chore: bump version to 0.14

* chore: bump version to 0.14.0

* chore: bump version to 0.13.3

* update
  • Loading branch information
sundy-li authored Mar 13, 2024
1 parent 9290c2a commit 73b4c8d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bindings/nodejs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion sql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 6 additions & 4 deletions sql/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -525,9 +526,9 @@ impl TryFrom<Value> 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()),
}
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 73b4c8d

Please sign in to comment.