Skip to content

Commit

Permalink
Bump chrono to 0.4.27 (vectordotdev#18436)
Browse files Browse the repository at this point in the history
* Bump `chrono` to 0.4.27

* More fixes
  • Loading branch information
bruceg authored Aug 30, 2023
1 parent ce7da4e commit e9feabd
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 29 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ bloomy = { version = "1.2.0", default-features = false, optional = true }
bollard = { version = "0.14.0", default-features = false, features = ["ssl", "chrono"], optional = true }
bytes = { version = "1.4.0", default-features = false, features = ["serde"] }
bytesize = { version = "1.3.0", default-features = false }
chrono = { version = "0.4.26", default-features = false, features = ["serde"] }
chrono = { version = "0.4.27", default-features = false, features = ["serde"] }
cidr-utils = { version = "0.5.10", default-features = false }
clap = { version = "4.4.1", default-features = false, features = ["derive", "error-context", "env", "help", "std", "string", "usage", "wrap_help"] }
colored = { version = "2.0.4", default-features = false }
Expand Down Expand Up @@ -382,7 +382,7 @@ zstd = { version = "0.12.4", default-features = false }
[patch.crates-io]
# Removes dependency on `time` v0.1
# https://github.com/chronotope/chrono/pull/578
chrono = { git = "https://github.com/vectordotdev/chrono.git", tag = "v0.4.26-no-default-time-1" }
chrono = { git = "https://github.com/vectordotdev/chrono.git", tag = "v0.4.27-no-default-time-1" }
# The upgrade for `tokio-util` >= 0.6.9 is blocked on https://github.com/vectordotdev/vector/issues/11257.
tokio-util = { git = "https://github.com/vectordotdev/tokio", branch = "tokio-util-0.7.8-framed-read-continue-on-error" }
nix = { git = "https://github.com/vectordotdev/nix.git", branch = "memfd/gnu/musl" }
Expand Down
11 changes: 4 additions & 7 deletions lib/codecs/src/decoding/format/gelf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bytes::Bytes;
use chrono::{DateTime, NaiveDateTime, Utc};
use chrono::{NaiveDateTime, Utc};
use derivative::Derivative;
use lookup::{event_path, owned_value_path};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -138,7 +138,7 @@ impl GelfDeserializer {
f64::fract(timestamp) as u32,
)
.expect("invalid timestamp");
log.insert(timestamp_key, DateTime::<Utc>::from_utc(naive, Utc));
log.insert(timestamp_key, naive.and_utc());
// per GELF spec- add timestamp if not provided
} else {
log.insert(timestamp_key, Utc::now());
Expand Down Expand Up @@ -239,7 +239,7 @@ impl Deserializer for GelfDeserializer {
mod tests {
use super::*;
use bytes::Bytes;
use chrono::{DateTime, NaiveDateTime, Utc};
use chrono::NaiveDateTime;
use lookup::event_path;
use serde_json::json;
use similar_asserts::assert_eq;
Expand Down Expand Up @@ -304,10 +304,7 @@ mod tests {
);
// Vector does not use the nanos
let naive = NaiveDateTime::from_timestamp_opt(1385053862, 0).expect("invalid timestamp");
assert_eq!(
log.get(TIMESTAMP),
Some(&Value::Timestamp(DateTime::<Utc>::from_utc(naive, Utc)))
);
assert_eq!(log.get(TIMESTAMP), Some(&Value::Timestamp(naive.and_utc())));
assert_eq!(log.get(LEVEL), Some(&Value::Integer(1)));
assert_eq!(
log.get(FACILITY),
Expand Down
6 changes: 3 additions & 3 deletions lib/codecs/src/encoding/format/gelf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ mod tests {
use crate::encoding::SerializerConfig;

use super::*;
use chrono::{DateTime, NaiveDateTime, Utc};
use chrono::NaiveDateTime;
use vector_core::event::{Event, EventMetadata};
use vrl::btreemap;
use vrl::value::Value;
Expand Down Expand Up @@ -347,7 +347,7 @@ mod tests {
{
let naive_dt =
NaiveDateTime::parse_from_str("1970-01-01 00:00:00.1", "%Y-%m-%d %H:%M:%S%.f");
let dt = DateTime::<Utc>::from_utc(naive_dt.unwrap(), Utc);
let dt = naive_dt.unwrap().and_utc();

let event_fields = btreemap! {
VERSION => "1.1",
Expand All @@ -365,7 +365,7 @@ mod tests {
{
let naive_dt =
NaiveDateTime::parse_from_str("1970-01-01 00:00:00.0", "%Y-%m-%d %H:%M:%S%.f");
let dt = DateTime::<Utc>::from_utc(naive_dt.unwrap(), Utc);
let dt = naive_dt.unwrap().and_utc();

let event_fields = btreemap! {
VERSION => "1.1",
Expand Down
7 changes: 3 additions & 4 deletions lib/vector-core/src/event/test/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ fn datetime(g: &mut Gen) -> DateTime<Utc> {
// are. We just sort of arbitrarily restrict things.
let secs = i64::arbitrary(g) % 32_000;
let nanosecs = u32::arbitrary(g) % 32_000;
DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp_opt(secs, nanosecs).expect("invalid timestamp"),
Utc,
)
NaiveDateTime::from_timestamp_opt(secs, nanosecs)
.expect("invalid timestamp")
.and_utc()
}

impl Arbitrary for Event {
Expand Down
18 changes: 8 additions & 10 deletions src/sources/gcp_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
time::Duration,
};

use chrono::{DateTime, NaiveDateTime, Utc};
use chrono::NaiveDateTime;
use codecs::decoding::{DeserializerConfig, FramingConfig};
use derivative::Derivative;
use futures::{stream, stream::FuturesUnordered, FutureExt, Stream, StreamExt, TryFutureExt};
Expand Down Expand Up @@ -673,11 +673,9 @@ impl PubsubSource {
"gcp_pubsub",
&message.data,
message.publish_time.map(|dt| {
DateTime::from_utc(
NaiveDateTime::from_timestamp_opt(dt.seconds, dt.nanos as u32)
.expect("invalid timestamp"),
Utc,
)
NaiveDateTime::from_timestamp_opt(dt.seconds, dt.nanos as u32)
.expect("invalid timestamp")
.and_utc()
}),
batch,
log_namespace,
Expand Down Expand Up @@ -840,6 +838,7 @@ mod integration_tests {
use std::collections::{BTreeMap, HashSet};

use base64::prelude::{Engine as _, BASE64_STANDARD};
use chrono::{DateTime, Utc};
use futures::{Stream, StreamExt};
use http::method::Method;
use hyper::{Request, StatusCode};
Expand Down Expand Up @@ -1003,10 +1002,9 @@ mod integration_tests {
fn now_trunc() -> DateTime<Utc> {
let start = Utc::now().timestamp();
// Truncate the milliseconds portion, the hard way.
DateTime::<Utc>::from_utc(
NaiveDateTime::from_timestamp_opt(start, 0).expect("invalid timestamp"),
Utc,
)
NaiveDateTime::from_timestamp_opt(start, 0)
.expect("invalid timestamp")
.and_utc()
}

struct Tester {
Expand Down

0 comments on commit e9feabd

Please sign in to comment.