Skip to content

Commit 80d1568

Browse files
committed
date: honor narrow width on wide default strftime fields
1 parent fca0d04 commit 80d1568

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

src/uu/date/src/format_modifiers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,9 @@ fn apply_modifiers(
356356
width
357357
};
358358

359-
// Handle width smaller than result: strip default padding to fit
359+
// When the requested width is narrower than the default formatted width, GNU first removes default padding and then reapplies the requested width.
360360
if effective_width > 0 && effective_width < result.len() {
361-
return Ok(strip_default_padding(&result));
361+
result = strip_default_padding(&result);
362362
}
363363

364364
// Strip default padding when switching pad characters on numeric fields

tests/by-util/test_date.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,6 @@ fn test_date_parenthesis_comment() {
18271827
}
18281828

18291829
#[test]
1830-
#[ignore = "https://github.com/uutils/coreutils/issues/11660 — GNU date pads to the requested width when it is narrower than the default (e.g. `%02j` on day-1 -> `01`); uutils strips leading zeros to `1`."]
18311830
fn test_date_strftime_narrow_width_on_wide_default() {
18321831
// `%j` has a default width of 3. Requesting `%02j` on day 1 should yield `01`.
18331832
// uutils currently yields `1`.

0 commit comments

Comments
 (0)