Skip to content

Conversation

@cerdelen
Copy link
Contributor

@cerdelen cerdelen commented Dec 22, 2025

fixes #9775.

I fixed the bug described in this issue and also added regression tests.

I am pretty sure that the unwrap i added is not okay but i am not sure what fallback date to use if the edgecases of the time is reached and would love for someone to give me some input.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 22, 2025

CodSpeed Performance Report

Merging #9785 will not alter performance

Comparing cerdelen:fix_date_military_parsing (df7f94c) with main (cc103ec)

Summary

✅ 127 untouched
⏩ 6 skipped1

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/tail/retry. tests/tail/retry is passing on 'main'. Maybe you have to rebase?

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/tty/tty-eof. tests/tty/tty-eof is passing on 'main'. Maybe you have to rebase?

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

cerdelen and others added 2 commits December 23, 2025 10:44
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/csplit/csplit-heap is now being skipped but was previously passing.
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.

@cerdelen
Copy link
Contributor Author

also fixes #9798

@sylvestre
Copy link
Contributor

@cerdelen could you please update this PR with the test cases from #9798 ?
thanks

Comment on lines 335 to 347
let date_part = match day_delta {
DayDelta::Same => {
strtime::format("%F", &now).unwrap_or_else(|_| String::from("1970-01-01"))
}
DayDelta::Next => now
.tomorrow()
.and_then(|d| strtime::format("%F", &d))
.unwrap_or_else(|_| String::from("1970-01-01")),
DayDelta::Previous => now
.yesterday()
.and_then(|d| strtime::format("%F", &d))
.unwrap_or_else(|_| String::from("1970-01-01")),
};
Copy link
Contributor

Choose a reason for hiding this comment

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

can probably simplified with something like:

Suggested change
let date_part = match day_delta {
DayDelta::Same => {
strtime::format("%F", &now).unwrap_or_else(|_| String::from("1970-01-01"))
}
DayDelta::Next => now
.tomorrow()
.and_then(|d| strtime::format("%F", &d))
.unwrap_or_else(|_| String::from("1970-01-01")),
DayDelta::Previous => now
.yesterday()
.and_then(|d| strtime::format("%F", &d))
.unwrap_or_else(|_| String::from("1970-01-01")),
};
let format_date = |date: Option<Zoned>| -> String {
date.and_then(|d| strtime::format("%F", &d))
.unwrap_or_else(|_| String::from("1970-01-01"))
};
let date_part = match day_delta {
DayDelta::Same => format_date(Some(now)),
DayDelta::Next => format_date(now.tomorrow()),
DayDelta::Previous => format_date(now.yesterday()),
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tomorrow()/yesterday() return Result but i did implement this closure approach in the newest commit

@cerdelen
Copy link
Contributor Author

cerdelen commented Dec 24, 2025

@cerdelen could you please update this PR with the test cases from #9798 ? thanks

line 1117 in file tests/by-util/test_date.rs already tests this explicitly for correct time

and i extended my test with this variation too to checks that the date is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Military timezone parsing shows incorrect date (1 day ahead)

2 participants