diff --git a/src/format/strftime.rs b/src/format/strftime.rs index 2fd6da0351..2a21be98d0 100644 --- a/src/format/strftime.rs +++ b/src/format/strftime.rs @@ -755,9 +755,9 @@ fn test_strftime_docs() { assert_eq!(dt.format("%%").unwrap().to_string(), "%"); // complex format specifiers - assert_eq!(dt.format(" %Y%d%m%%%%%t%H%M%S\t").to_string(), " 20010807%%\t003460\t"); + assert_eq!(dt.format(" %Y%d%m%%%%%t%H%M%S\t").unwrap().to_string(), " 20010807%%\t003460\t"); assert_eq!( - dt.format(" %Y%d%m%%%%%t%H:%P:%M%S%:::z\t").to_string(), + dt.format(" %Y%d%m%%%%%t%H:%P:%M%S%:::z\t").unwrap().to_string(), " 20010807%%\t00:am:3460+09\t" ); } diff --git a/src/naive/datetime/tests.rs b/src/naive/datetime/tests.rs index 76d2adff13..be9df12916 100644 --- a/src/naive/datetime/tests.rs +++ b/src/naive/datetime/tests.rs @@ -20,7 +20,7 @@ fn test_datetime_from_timestamp_millis() { for (timestamp_millis, formatted) in valid_map.iter().copied() { let naive_datetime = NaiveDateTime::from_timestamp_millis(timestamp_millis); assert_eq!(timestamp_millis, naive_datetime.unwrap().timestamp_millis()); - assert_eq!(naive_datetime.unwrap().format("%F %T%.9f").to_string(), formatted); + assert_eq!(naive_datetime.unwrap().format("%F %T%.9f").unwrap().to_string(), formatted); } let invalid = [i64::MAX, i64::MIN]; @@ -57,7 +57,7 @@ fn test_datetime_from_timestamp_micros() { for (timestamp_micros, formatted) in valid_map.iter().copied() { let naive_datetime = NaiveDateTime::from_timestamp_micros(timestamp_micros); assert_eq!(timestamp_micros, naive_datetime.unwrap().timestamp_micros()); - assert_eq!(naive_datetime.unwrap().format("%F %T%.9f").to_string(), formatted); + assert_eq!(naive_datetime.unwrap().format("%F %T%.9f").unwrap().to_string(), formatted); } let invalid = [i64::MAX, i64::MIN]; diff --git a/tests/dateutils.rs b/tests/dateutils.rs index aabab29a78..a9b2d566e2 100644 --- a/tests/dateutils.rs +++ b/tests/dateutils.rs @@ -110,7 +110,7 @@ fn verify_against_date_command_format_local(path: &'static str, dt: NaiveDateTim let ldt = Local .from_local_datetime(&date.and_hms_opt(dt.hour(), dt.minute(), dt.second()).unwrap()) .unwrap(); - let formated_date = format!("{}\n", ldt.format(required_format)); + let formated_date = format!("{}\n", ldt.format(required_format).unwrap()); assert_eq!(date_command_str, formated_date); }