Skip to content

date: accept dotted calendar dates - #350

Merged
sylvestre merged 2 commits into
uutils:mainfrom
anastygnome:fixes/dotted-dates
Nov 11, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
anastygnome:fixes/dotted-dates

Conversation

@anastygnome

@anastygnome anastygnome commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Add GNU-compatible dotted calendar date parsing with regression coverage.

Copilot AI balanced review requested due to automatic review settings November 8, 2026 15:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.93%. Comparing base (9f21506) to head (9532b6b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #350      +/-   ##
==========================================
+ Coverage   98.90%   98.93%   +0.03%     
==========================================
  Files          21       21              
  Lines        4572     4611      +39     
  Branches      142      142              
==========================================
+ Hits         4522     4562      +40     
+ Misses         49       48       -1     
  Partials        1        1              
Flag Coverage Δ
macos_latest 98.93% <100.00%> (+0.03%) ⬆️
ubuntu_latest 98.93% <100.00%> (+0.03%) ⬆️
windows_latest 12.23% <27.50%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI balanced review requested due to automatic review settings November 8, 2026 20:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Comment thread src/items/date.rs Outdated
Comment on lines +138 to +140
/// A year belongs to the dotted date only when it immediately follows the
/// second dot. With whitespace after that dot, GNU treats the number as a
/// separate item instead.

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.

I think this comment is incorrect, or I'm missing something. The following example works with GNU date:

$ date -d "14  .  11  .   2022"
Mon Nov 14 12:00:00 AM CET 2022

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.

yep, right, my test script had issues

Comment thread src/items/date.rs Outdated
s(dec_uint),
s('.'),
s(dec_uint),
'.',

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.

See my previous comment.

        s('.'),

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.

yep

Comment thread src/items/date.rs Outdated

match year {
Some(year) => {
year_from_str(year).map_err(|e| ErrMode::Backtrack(ctx_err(e)))?;

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.

do we need this? try_into() already calls year_from_str

Comment thread src/items/date.rs Outdated
alt((dotted, us, literal1, literal2, literal3)).parse_next(input)
}

/// Parse the European `DD.MM[.][YYYY]` spelling.

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.

the second dot is mandatory in the code, so 14.11 is rejected
should it be DD.MM.[YYYY]?

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.

yep, wrong script on my side

Comment thread src/items/date.rs Resolved
Comment thread src/items/date.rs Outdated
s('.'),
s(dec_uint),
'.',
opt(take_while(1.., AsChar::is_dec_digit)),

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.

literal1 requires the year to be followed by a space or eof, why not here?

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.

fixed

Copilot AI balanced review requested due to automatic review settings November 9, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codspeed

codspeed Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 15 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 21 untouched benchmarks


Comparing anastygnome:fixes/dotted-dates (9532b6b) with main (9f21506)

Open in CodSpeed

Copilot AI balanced review requested due to automatic review settings November 10, 2026 09:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@anastygnome

Copy link
Copy Markdown
Contributor Author

regresion is normal, added work

Copilot AI balanced review requested due to automatic review settings November 10, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Comment thread src/items/date.rs
"Format string: {input}"
);
}

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.

please also add a test in tests/date.rs (with a 2-digit year too, e.g. 14.11.22)

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.

done

Comment thread src/items/date.rs Outdated
)
.parse_next(input)?;

match year {

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.

the same map_err in both arms, could be dedup, no?

@anastygnome
anastygnome force-pushed the fixes/dotted-dates branch 2 times, most recently from a8614b1 to 84acf61 Compare November 11, 2026 08:34
@sylvestre
sylvestre merged commit 830de3d into uutils:main Nov 11, 2026
15 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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.

4 participants