|
3 | 3 | // For the full copyright and license information, please view the LICENSE |
4 | 4 | // file that was distributed with this source code. |
5 | 5 |
|
6 | | -use chrono::{DateTime, Local}; |
7 | 6 | use clap::{Arg, ArgAction, ArgMatches, Command, builder::PossibleValue}; |
8 | 7 | use glob::Pattern; |
9 | 8 | use std::collections::{HashMap, HashSet}; |
10 | 9 | use std::env; |
11 | 10 | #[cfg(not(windows))] |
12 | 11 | use std::fs::Metadata; |
13 | 12 | use std::fs::{self, DirEntry, File}; |
14 | | -use std::io::{BufRead, BufReader}; |
| 13 | +use std::io::{BufRead, BufReader, stdout}; |
15 | 14 | #[cfg(not(windows))] |
16 | 15 | use std::os::unix::fs::MetadataExt; |
17 | 16 | #[cfg(windows)] |
@@ -576,13 +575,13 @@ impl StatPrinter { |
576 | 575 | } |
577 | 576 |
|
578 | 577 | fn print_stat(&self, stat: &Stat, size: u64) -> UResult<()> { |
| 578 | + print!("{}\t", self.convert_size(size)); |
| 579 | + |
579 | 580 | if let Some(time) = self.time { |
580 | 581 | let secs = get_time_secs(time, stat)?; |
581 | | - let tm = DateTime::<Local>::from(UNIX_EPOCH + Duration::from_secs(secs)); |
582 | | - let time_str = tm.format(&self.time_format).to_string(); |
583 | | - print!("{}\t{time_str}\t", self.convert_size(size)); |
584 | | - } else { |
585 | | - print!("{}\t", self.convert_size(size)); |
| 582 | + let time = UNIX_EPOCH + Duration::from_secs(secs); |
| 583 | + uucore::time::format_system_time(&mut stdout(), time, &self.time_format)?; |
| 584 | + print!("\t"); |
586 | 585 | } |
587 | 586 |
|
588 | 587 | print_verbatim(&stat.path).unwrap(); |
|
0 commit comments