From 6c2d090669fa7e04a793b1b4b07424a819b0e721 Mon Sep 17 00:00:00 2001 From: fdai7375 Date: Thu, 2 Feb 2023 21:00:34 +0100 Subject: [PATCH] test: add format time RFC3339 test --- src/builtins/time.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/builtins/time.rs b/src/builtins/time.rs index dbf47af..b4c1e2e 100644 --- a/src/builtins/time.rs +++ b/src/builtins/time.rs @@ -1,4 +1,4 @@ -use chrono::{DateTime, Local, Utc}; +use chrono::{DateTime, Utc}; use crate::error::ShellError; @@ -27,9 +27,8 @@ fn format_time(time: DateTime, formatting: &str) -> String { #[cfg(test)] mod tests { - use std::str::FromStr; - use chrono::{NaiveDate, NaiveDateTime, NaiveTime, TimeZone}; + use chrono::TimeZone; use super::*; @@ -46,4 +45,10 @@ mod tests { "Thu, 20 Apr 6969 04:20:09 +0000" ) } + + #[test] + fn test_format_time_rfc3339() { + let time = chrono::Utc.with_ymd_and_hms(6969, 4, 20, 4, 20, 9).unwrap(); + assert_eq!(format_time(time, "RFC3339"), "6969-04-20T04:20:09+00:00") + } }