Skip to content

Commit e9feabd

Browse files
authored
Bump chrono to 0.4.27 (vectordotdev#18436)
* Bump `chrono` to 0.4.27 * More fixes
1 parent ce7da4e commit e9feabd

File tree

6 files changed

+23
-29
lines changed

6 files changed

+23
-29
lines changed

Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ bloomy = { version = "1.2.0", default-features = false, optional = true }
253253
bollard = { version = "0.14.0", default-features = false, features = ["ssl", "chrono"], optional = true }
254254
bytes = { version = "1.4.0", default-features = false, features = ["serde"] }
255255
bytesize = { version = "1.3.0", default-features = false }
256-
chrono = { version = "0.4.26", default-features = false, features = ["serde"] }
256+
chrono = { version = "0.4.27", default-features = false, features = ["serde"] }
257257
cidr-utils = { version = "0.5.10", default-features = false }
258258
clap = { version = "4.4.1", default-features = false, features = ["derive", "error-context", "env", "help", "std", "string", "usage", "wrap_help"] }
259259
colored = { version = "2.0.4", default-features = false }
@@ -382,7 +382,7 @@ zstd = { version = "0.12.4", default-features = false }
382382
[patch.crates-io]
383383
# Removes dependency on `time` v0.1
384384
# https://github.com/chronotope/chrono/pull/578
385-
chrono = { git = "https://github.com/vectordotdev/chrono.git", tag = "v0.4.26-no-default-time-1" }
385+
chrono = { git = "https://github.com/vectordotdev/chrono.git", tag = "v0.4.27-no-default-time-1" }
386386
# The upgrade for `tokio-util` >= 0.6.9 is blocked on https://github.com/vectordotdev/vector/issues/11257.
387387
tokio-util = { git = "https://github.com/vectordotdev/tokio", branch = "tokio-util-0.7.8-framed-read-continue-on-error" }
388388
nix = { git = "https://github.com/vectordotdev/nix.git", branch = "memfd/gnu/musl" }

lib/codecs/src/decoding/format/gelf.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bytes::Bytes;
2-
use chrono::{DateTime, NaiveDateTime, Utc};
2+
use chrono::{NaiveDateTime, Utc};
33
use derivative::Derivative;
44
use lookup::{event_path, owned_value_path};
55
use serde::{Deserialize, Serialize};
@@ -138,7 +138,7 @@ impl GelfDeserializer {
138138
f64::fract(timestamp) as u32,
139139
)
140140
.expect("invalid timestamp");
141-
log.insert(timestamp_key, DateTime::<Utc>::from_utc(naive, Utc));
141+
log.insert(timestamp_key, naive.and_utc());
142142
// per GELF spec- add timestamp if not provided
143143
} else {
144144
log.insert(timestamp_key, Utc::now());
@@ -239,7 +239,7 @@ impl Deserializer for GelfDeserializer {
239239
mod tests {
240240
use super::*;
241241
use bytes::Bytes;
242-
use chrono::{DateTime, NaiveDateTime, Utc};
242+
use chrono::NaiveDateTime;
243243
use lookup::event_path;
244244
use serde_json::json;
245245
use similar_asserts::assert_eq;
@@ -304,10 +304,7 @@ mod tests {
304304
);
305305
// Vector does not use the nanos
306306
let naive = NaiveDateTime::from_timestamp_opt(1385053862, 0).expect("invalid timestamp");
307-
assert_eq!(
308-
log.get(TIMESTAMP),
309-
Some(&Value::Timestamp(DateTime::<Utc>::from_utc(naive, Utc)))
310-
);
307+
assert_eq!(log.get(TIMESTAMP), Some(&Value::Timestamp(naive.and_utc())));
311308
assert_eq!(log.get(LEVEL), Some(&Value::Integer(1)));
312309
assert_eq!(
313310
log.get(FACILITY),

lib/codecs/src/encoding/format/gelf.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ mod tests {
243243
use crate::encoding::SerializerConfig;
244244

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

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

370370
let event_fields = btreemap! {
371371
VERSION => "1.1",

lib/vector-core/src/event/test/common.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ fn datetime(g: &mut Gen) -> DateTime<Utc> {
5555
// are. We just sort of arbitrarily restrict things.
5656
let secs = i64::arbitrary(g) % 32_000;
5757
let nanosecs = u32::arbitrary(g) % 32_000;
58-
DateTime::<Utc>::from_utc(
59-
NaiveDateTime::from_timestamp_opt(secs, nanosecs).expect("invalid timestamp"),
60-
Utc,
61-
)
58+
NaiveDateTime::from_timestamp_opt(secs, nanosecs)
59+
.expect("invalid timestamp")
60+
.and_utc()
6261
}
6362

6463
impl Arbitrary for Event {

src/sources/gcp_pubsub.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
time::Duration,
55
};
66

7-
use chrono::{DateTime, NaiveDateTime, Utc};
7+
use chrono::NaiveDateTime;
88
use codecs::decoding::{DeserializerConfig, FramingConfig};
99
use derivative::Derivative;
1010
use futures::{stream, stream::FuturesUnordered, FutureExt, Stream, StreamExt, TryFutureExt};
@@ -673,11 +673,9 @@ impl PubsubSource {
673673
"gcp_pubsub",
674674
&message.data,
675675
message.publish_time.map(|dt| {
676-
DateTime::from_utc(
677-
NaiveDateTime::from_timestamp_opt(dt.seconds, dt.nanos as u32)
678-
.expect("invalid timestamp"),
679-
Utc,
680-
)
676+
NaiveDateTime::from_timestamp_opt(dt.seconds, dt.nanos as u32)
677+
.expect("invalid timestamp")
678+
.and_utc()
681679
}),
682680
batch,
683681
log_namespace,
@@ -840,6 +838,7 @@ mod integration_tests {
840838
use std::collections::{BTreeMap, HashSet};
841839

842840
use base64::prelude::{Engine as _, BASE64_STANDARD};
841+
use chrono::{DateTime, Utc};
843842
use futures::{Stream, StreamExt};
844843
use http::method::Method;
845844
use hyper::{Request, StatusCode};
@@ -1003,10 +1002,9 @@ mod integration_tests {
10031002
fn now_trunc() -> DateTime<Utc> {
10041003
let start = Utc::now().timestamp();
10051004
// Truncate the milliseconds portion, the hard way.
1006-
DateTime::<Utc>::from_utc(
1007-
NaiveDateTime::from_timestamp_opt(start, 0).expect("invalid timestamp"),
1008-
Utc,
1009-
)
1005+
NaiveDateTime::from_timestamp_opt(start, 0)
1006+
.expect("invalid timestamp")
1007+
.and_utc()
10101008
}
10111009

10121010
struct Tester {

0 commit comments

Comments
 (0)