Browse Source

test: add format time RFC3339 test

main
fdai7375 2 years ago
committed by fdai7451
parent
commit
6c2d090669
  1. 11
      src/builtins/time.rs

11
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<Utc>, 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")
}
}
Loading…
Cancel
Save