1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 11:07:44 +00:00

ls: switch to lenient formating configuration

This commit is contained in:
Nicolas Boichat 2025-05-01 10:58:38 +08:00
parent 10fb220c72
commit 6031de5a29

View file

@ -289,21 +289,24 @@ impl TimeStyle {
) -> Result<(), jiff::Error> { ) -> Result<(), jiff::Error> {
let recent = is_recent(date.timestamp(), state); let recent = is_recent(date.timestamp(), state);
let tm = BrokenDownTime::from(&date); let tm = BrokenDownTime::from(&date);
let out = StdIoWrite(out); let mut out = StdIoWrite(out);
let config = jiff::fmt::strtime::Config::new().lenient(true);
match (self, recent) { match (self, recent) {
(Self::FullIso, _) => tm.format("%Y-%m-%d %H:%M:%S.%f %z", out), (Self::FullIso, _) => {
(Self::LongIso, _) => tm.format("%Y-%m-%d %H:%M", out), tm.format_with_config(&config, "%Y-%m-%d %H:%M:%S.%f %z", &mut out)
(Self::Iso, true) => tm.format("%m-%d %H:%M", out), }
(Self::Iso, false) => tm.format("%Y-%m-%d ", out), (Self::LongIso, _) => tm.format_with_config(&config, "%Y-%m-%d %H:%M", &mut out),
(Self::Iso, true) => tm.format_with_config(&config, "%m-%d %H:%M", &mut out),
(Self::Iso, false) => tm.format_with_config(&config, "%Y-%m-%d ", &mut out),
// spell-checker:ignore (word) datetime // spell-checker:ignore (word) datetime
//In this version of chrono translating can be done //In this version of chrono translating can be done
//The function is chrono::datetime::DateTime::format_localized //The function is chrono::datetime::DateTime::format_localized
//However it's currently still hard to get the current pure-rust-locale //However it's currently still hard to get the current pure-rust-locale
//So it's not yet implemented //So it's not yet implemented
(Self::Locale, true) => tm.format("%b %e %H:%M", out), (Self::Locale, true) => tm.format_with_config(&config, "%b %e %H:%M", &mut out),
(Self::Locale, false) => tm.format("%b %e %Y", out), (Self::Locale, false) => tm.format_with_config(&config, "%b %e %Y", &mut out),
(Self::Format(fmt), _) => tm.format(&fmt, out), (Self::Format(fmt), _) => tm.format_with_config(&config, fmt, &mut out),
} }
} }
} }