From 28065de413f1d392842aaf332e0b26b144998eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 12 Nov 2022 18:41:08 +0200 Subject: [PATCH] closedcaption: Update for deprecated chrono functions Part-of: --- video/closedcaption/Cargo.toml | 2 +- video/closedcaption/src/mcc_enc/imp.rs | 31 ++++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/video/closedcaption/Cargo.toml b/video/closedcaption/Cargo.toml index a0653931..8c0c1665 100644 --- a/video/closedcaption/Cargo.toml +++ b/video/closedcaption/Cargo.toml @@ -13,7 +13,7 @@ anyhow = "1" nom = "7.0" either = "1" uuid = { version = "1.0", features = ["v4"] } -chrono = "0.4" +chrono = "0.4.23" once_cell = "1.0" atomic_refcell = "0.1" cairo-rs = { git = "https://github.com/gtk-rs/gtk-rs-core", branch = "0.16", version = "0.16", features=["use_glib"] } diff --git a/video/closedcaption/src/mcc_enc/imp.rs b/video/closedcaption/src/mcc_enc/imp.rs index e4fbdfd8..9d476206 100644 --- a/video/closedcaption/src/mcc_enc/imp.rs +++ b/video/closedcaption/src/mcc_enc/imp.rs @@ -99,20 +99,23 @@ impl MccEnc { ); if let Some(ref creation_date) = settings.creation_date { - let creation_date = Utc - .ymd( - creation_date.year() as i32, - creation_date.month() as u32, - creation_date.day_of_month() as u32, - ) - .and_hms( - creation_date.hour() as u32, - creation_date.minute() as u32, - creation_date.seconds() as u32, - ) - .with_timezone(&FixedOffset::east( - creation_date.utc_offset().as_seconds() as i32 - )); + let creation_date = + FixedOffset::east_opt(creation_date.utc_offset().as_seconds() as i32) + .and_then(|tz| { + tz.with_ymd_and_hms( + creation_date.year() as i32, + creation_date.month() as u32, + creation_date.day_of_month() as u32, + creation_date.hour() as u32, + creation_date.minute() as u32, + creation_date.seconds() as u32, + ) + .latest() + }) + .ok_or_else(|| { + gst::error!(CAT, imp: self, "Invalid creation datetime"); + gst::FlowError::Error + })?; let _ = write!( buffer,