Repository navigation
date: drop the E modifier in the C locale - #15237
yu2971512385-ui wants to merge 1 commit into
Conversation
|
GNU testsuite comparison: |
| } | ||
| match chars.peek() { | ||
| Some('O') => { | ||
| Some(&modifier @ ('O' | 'E')) => { |
There was a problem hiding this comment.
what happens with a flag or width before the modifier, like %-Ey or %10EY? please add a test
| .env("TZ", "UTC") | ||
| .arg("-d") | ||
| .arg("2024-06-15") | ||
| .arg("+%Ey-%EY-%EC") |
There was a problem hiding this comment.
please also cover %Ec, %Ex and %EX, they are in the list but not tested
c31213f to
b2dc0be
Compare
%Ey and the other five conversions POSIX pairs the E modifier with were passed through to jiff, which does not know the modifier and printed them literally: `date -d @1234567890 +%Ey` gave `%Ey` where GNU gives `09`. The C locale has no era representation, so the modifier falls back to the plain conversion, exactly as %O already does. strip_o_modifier handled only O, so it now handles both and is renamed to match. E is dropped only before c, C, x, X, y and Y, since GNU keeps the others literal, and a dangling %E or one behind %% stays literal as before. Both modifiers sit behind the GNU flags and field width, as in `%-Oy` or `%10EY`, so those are now skipped while looking for the modifier. That also fixes %O, which printed `%Oy` for `%-Oy` and `00000000%OY` for `%10OY`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
b2dc0be to
ef60c6c
Compare
|
Thanks for the review. Written with AI assistance on my behalf, as with the PR itself; the measurements below are from GNU coreutils 9.x and this branch on macOS 15. Both cases were already broken for The modifier scan started at Added as Three cases still differ, and I did not want to guess at them: GNU renders an E-modified year as an era string, so it pads with spaces and |
date +%Eyprinted%Eyinstead of the year. The six conversions POSIX pairsthe
Emodifier with (%Ec %EC %Ex %EX %Ey %EY) all went through to jiff,which does not know the modifier and emits it literally.
In the C locale there is no era representation, so
Efalls back to the plainconversion — the same rule
%Oalready follows since #11656.strip_o_modifieronly looked for
O, so it now looks for both and is renamed accordingly.Eisdropped only before
c,C,x,X,yandY, because GNU leaves theother letters literal; a dangling
%E,%E9or anEbehind%%staysliteral as before, and
%Ohandling is unchanged.Checked against GNU coreutils 9.x with
LC_ALL=C TZ=UTC:%Ey%Ey09%EY%EY2009%EC%EC20%Ex%Ex02/13/09%EX%EX23:31:30%Ec%EcFri Feb 13 23:31:30 2009%Ej,%E,%E9,%%EyPart of #10958. It does not close it: that issue also asks for the ICU-backed
alternative representations, which #10994 is about — this only completes the
C-locale fallback that
%Oalready had.🤖 Generated with Claude Code