Skip to content

Commit ada1989

Browse files
authored
Avoid multiple trim()
1 parent a8d5470 commit ada1989

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/uu/date/src/date.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,21 +256,22 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
256256
// Iterate over all dates - whether it's a single date or a file.
257257
let dates: Box<dyn Iterator<Item = _>> = match settings.date_source {
258258
DateSource::Human(ref input) => {
259+
let input = input.trim();
259260
// GNU compatibility (Empty string):
260261
// An empty string (or whitespace-only) should be treated as midnight today.
261-
let is_empty_or_whitespace = input.trim().is_empty();
262+
let is_empty_or_whitespace = input.is_empty();
262263

263264
// GNU compatibility (Military timezone 'J'):
264265
// 'J' is reserved for local time in military timezones.
265266
// GNU date accepts it and treats it as midnight today (00:00:00).
266-
let is_military_j = input.trim().eq_ignore_ascii_case("j");
267+
let is_military_j = input.eq_ignore_ascii_case("j");
267268

268269
// GNU compatibility (Military timezone with optional hour offset):
269270
// Single letter (a-z except j) optionally followed by 1-2 digits.
270271
// Letter represents midnight in that military timezone (UTC offset).
271272
// Digits represent additional hours to add.
272273
// Examples: "m" -> noon UTC (12:00); "m9" -> 21:00 UTC; "a5" -> 04:00 UTC
273-
let military_tz_with_offset = parse_military_timezone_with_offset(input.trim());
274+
let military_tz_with_offset = parse_military_timezone_with_offset(input);
274275

275276
// GNU compatibility (Pure numbers in date strings):
276277
// - Manual: https://www.gnu.org/software/coreutils/manual/html_node/Pure-numbers-in-date-strings.html

0 commit comments

Comments
 (0)