From 4310bf814cdede5daa5181fdf4588d3f65d771f8 Mon Sep 17 00:00:00 2001 From: Wei Zhang Date: Fri, 22 Mar 2024 01:19:59 +0800 Subject: [PATCH] :construction: temporarily allow deprecated duration will fix in next release Signed-off-by: Wei Zhang --- src/meta/date.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/meta/date.rs b/src/meta/date.rs index e7ded162f..007023c35 100644 --- a/src/meta/date.rs +++ b/src/meta/date.rs @@ -34,6 +34,7 @@ impl From<&Metadata> for Date { impl Date { pub fn render(&self, colors: &Colors, flags: &Flags) -> ColoredString { let now = Local::now(); + #[allow(deprecated)] let elem = match self { &Date::Date(modified) if modified > now - Duration::hours(1) => Elem::HourOld, &Date::Date(modified) if modified > now - Duration::days(1) => Elem::DayOld, @@ -46,6 +47,7 @@ impl Date { let locale = current_locale(); if let Date::Date(val) = self { + #[allow(deprecated)] match &flags.date { DateFlag::Date => val.format("%c").to_string(), DateFlag::Locale => val.format_localized("%c", locale).to_string(), @@ -119,6 +121,7 @@ mod test { let mut file_path = env::temp_dir(); file_path.push("test_an_hour_old_file_color.tmp"); + #[allow(deprecated)] let creation_date = Local::now() - chrono::Duration::seconds(4); let success = cross_platform_touch(&file_path, &creation_date) @@ -146,6 +149,7 @@ mod test { let mut file_path = env::temp_dir(); file_path.push("test_a_day_old_file_color.tmp"); + #[allow(deprecated)] let creation_date = Local::now() - chrono::Duration::hours(4); let success = cross_platform_touch(&file_path, &creation_date) @@ -173,6 +177,7 @@ mod test { let mut file_path = env::temp_dir(); file_path.push("test_a_several_days_old_file_color.tmp"); + #[allow(deprecated)] let creation_date = Local::now() - chrono::Duration::days(2); let success = cross_platform_touch(&file_path, &creation_date) @@ -200,6 +205,7 @@ mod test { let mut file_path = env::temp_dir(); file_path.push("test_with_relative_date.tmp"); + #[allow(deprecated)] let creation_date = Local::now() - chrono::Duration::days(2); let success = cross_platform_touch(&file_path, &creation_date) @@ -285,6 +291,7 @@ mod test { let mut file_path = env::temp_dir(); file_path.push("test_iso_format_year_old.tmp"); + #[allow(deprecated)] let creation_date = Local::now() - Duration::days(400); let success = cross_platform_touch(&file_path, &creation_date) .unwrap()