Skip to content

date: add support for dot-separated dates - #14614

Open
Devel08 wants to merge 1 commit into
uutils:mainfrom
Devel08:fix-issue-14604
Open

Devel08 wants to merge 1 commit into
uutils:mainfrom
Devel08:fix-issue-14604

Conversation

@Devel08

@Devel08 Devel08 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

closes #14604

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/misc/tty-eof (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tail/tail-n0f is now passing!

Comment thread src/uu/date/src/date.rs
/// Convert a date string to iso if it is seperated by dots.
fn convert_to_iso(date_str: &str) -> Option<String> {
// Seperate the date from anything else, in case we have something like "01.01.2008 03:00 p.m."
let mut parts = date_str.splitn(2, ' ');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is one exception where this approach will fail: GNU date allows spaces between month and year and so something like "01.01. 2008 03:00 p.m." is a valid date.

Comment thread src/uu/date/src/date.rs
Comment on lines +1187 to +1190
let date_subparts: Vec<&str> = date_part.split('.').collect();
if date_subparts.len() != 3 {
return None;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With GNU date the year is optional. If it is missing, the current year is used. And so something like "01.01. 03:00 p.m." is a valid date.

Comment thread src/uu/date/src/date.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might make sense to move the functionality over to https://github.com/uutils/parse_datetime . There we already use a parser library which could be helpful for the functionality I mentioned in the other comments.

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.

Yeah I was just looking for a such function there, anyways, should we add tests for dates like 01.01. 2008 03:00 p.m. and 01.01. 03:00 p.m.?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, please :)

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.

feat: date does not support dots, gnu does in 9.11

2 participants