Skip to content

Commit

Permalink
stat: move fn to fix clippy error
Browse files Browse the repository at this point in the history
  • Loading branch information
cakebaker authored Feb 13, 2024
1 parent 44a70df commit 6d6f8b6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/uu/stat/src/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,16 @@ pub fn uu_app() -> Command {
)
}

const PRETTY_DATETIME_FORMAT: &str = "%Y-%m-%d %H:%M:%S.%f %z";

fn pretty_time(sec: i64, nsec: i64) -> String {
// Return the date in UTC
let tm = chrono::DateTime::from_timestamp(sec, nsec as u32).unwrap_or_default();
let tm: DateTime<Local> = tm.into();

tm.format(PRETTY_DATETIME_FORMAT).to_string()
}

#[cfg(test)]
mod tests {
use super::{group_num, Flags, ScanUtil, Stater, Token};
Expand Down Expand Up @@ -1059,13 +1069,3 @@ mod tests {
assert_eq!(&expected, &Stater::generate_tokens(s, true).unwrap());
}
}

const PRETTY_DATETIME_FORMAT: &str = "%Y-%m-%d %H:%M:%S.%f %z";

fn pretty_time(sec: i64, nsec: i64) -> String {
// Return the date in UTC
let tm = chrono::DateTime::from_timestamp(sec, nsec as u32).unwrap_or_default();
let tm: DateTime<Local> = tm.into();

tm.format(PRETTY_DATETIME_FORMAT).to_string()
}

0 comments on commit 6d6f8b6

Please sign in to comment.