From f4612b8f8d9dc6e0c3462932e8e9d4c5c4a47c9b Mon Sep 17 00:00:00 2001 From: George Hilliard Date: Mon, 14 Dec 2020 22:37:15 -0600 Subject: [PATCH] Fix use of deprecated time::OffsetDateTime::now_local() --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 4ad0b98..29e60d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -239,7 +239,11 @@ fn do_camera_management( camera_config.name, time ); } else { - let new_time = time::OffsetDateTime::now_local(); + use time::OffsetDateTime; + // We'd like now_local() but it's deprecated - try to get the local time, but if no + // time zone, fall back to UTC. + let new_time = OffsetDateTime::try_now_local().unwrap_or(OffsetDateTime::now_utc()); + warn!( "{}: Camera has no time set, setting to {}", camera_config.name, new_time