From c3806280db08dd23af51b24357e5ed65d40e55f7 Mon Sep 17 00:00:00 2001 From: Ruslan Sayfutdinov Date: Thu, 31 Aug 2023 11:47:32 -0700 Subject: [PATCH] replace DateTime::from_utc() with .and_utc() Summary: Preparation to chrono upgrade to 0.4.28 which deprecates `DateTime::from_utc()`. Reviewed By: zertosh Differential Revision: D48866817 fbshipit-source-id: 1c3c344c4c076a02cce33c892d7ce1e1ed44db2a --- detcore/tests/time/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/detcore/tests/time/mod.rs b/detcore/tests/time/mod.rs index 37d05ee..d76f2cf 100644 --- a/detcore/tests/time/mod.rs +++ b/detcore/tests/time/mod.rs @@ -97,7 +97,7 @@ fn tod_gettimeofday() { let naive_time = NaiveDateTime::from_timestamp_opt(tp.tv_sec, 1000 * tp.tv_usec as u32).unwrap(); - let dt = DateTime::::from_utc(naive_time, Utc); + let dt = naive_time.and_utc(); // However exactly we compute logical time, this should be within a small // fraction of a (logical) second of epoch: assert!(diff_millis(dt, epoch) < 100); @@ -117,7 +117,7 @@ fn raw_getimeofday_delta() { let tp = unsafe { tp.assume_init() }; let naive_time = NaiveDateTime::from_timestamp_opt(tp.tv_sec, 1000 * tp.tv_usec as u32).unwrap(); - DateTime::::from_utc(naive_time, Utc) + naive_time.and_utc() }; let dt2 = { let mut tp: MaybeUninit = MaybeUninit::uninit(); @@ -128,7 +128,7 @@ fn raw_getimeofday_delta() { let tp = unsafe { tp.assume_init() }; let naive_time = NaiveDateTime::from_timestamp_opt(tp.tv_sec, 1000 * tp.tv_usec as u32).unwrap(); - DateTime::::from_utc(naive_time, Utc) + naive_time.and_utc() }; let delta_ns = diff_nanos(dt1, dt2); @@ -163,7 +163,7 @@ fn tod_time() { assert_eq!(t, tloc); let naive_time = NaiveDateTime::from_timestamp_opt(t, 0).unwrap(); - let dt = DateTime::::from_utc(naive_time, Utc); + let dt = naive_time.and_utc(); assert_eq!(dt.timestamp(), epoch.timestamp()); }, config, @@ -192,7 +192,7 @@ fn tod_clock_gettime() { let naive_time = NaiveDateTime::from_timestamp_opt(tp.tv_sec, tp.tv_nsec as u32).unwrap(); - let dt = DateTime::::from_utc(naive_time, Utc); + let dt = naive_time.and_utc(); // However exactly we compute logical time, this should be within a small // fraction of a (logical) second of epoch: assert!(diff_millis(dt, epoch) < 100);