Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ binary-heap-plus = "0.5.0"
bstr = "1.9.1"
bytecount = "0.6.8"
byteorder = "1.5.0"
chrono = { version = "0.4.38", default-features = false, features = [
chrono = { version = "0.4.41", default-features = false, features = [
"std",
"alloc",
"clock",
Expand Down
4 changes: 2 additions & 2 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,11 @@ impl TimeStyler {
// So it's not yet implemented
TimeStyle::Locale => StrftimeItems::new("%b %e %Y").parse(),
TimeStyle::Format(fmt) => {
// TODO (#7802): Replace with new_lenient
StrftimeItems::new(custom_tz_fmt::custom_time_format(fmt).as_str()).parse_to_owned()
// Box the fmt value to make it static.
StrftimeItems::new_lenient(Box::leak(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the Box::leak change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my bad. Was too concentrated on parse(), missed that it can be done much simpler

custom_tz_fmt::custom_time_format(fmt).into_boxed_str(),
))
.parse()
}
}
.unwrap();
Expand Down
10 changes: 10 additions & 0 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5705,3 +5705,13 @@ fn test_time_style_timezone_name() {
.succeeds()
.stdout_matches(&re_custom_format);
}

#[test]
fn test_unknown_format_specifier() {
let re_custom_format = Regex::new(r"[a-z-]* \d* [\w.]* [\w.]* \d+ \d{4} %0 \d{9} f\n").unwrap();
let (at, mut ucmd) = at_and_ucmd!();
at.touch("f");
ucmd.args(&["-l", "--time-style=+%Y %0 %N"])
.succeeds()
.stdout_matches(&re_custom_format);
}