Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date: fix %Z specifier does not print TZ abbr #5164

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

KrishnaNagam
Copy link

fixes issue #3756 for date util

description:
chrono crate ignores %Z specifier. only prints timezone offset. added crates chrono-tz and iana_time_zone to calculate the timezone abbreviation and replace %Z specifier with the the abbreviation.

@KrishnaNagam KrishnaNagam changed the title fix: replace %Z specifier with locale TZ abbr date: fix %Z specifier does not print TZ abbr Aug 15, 2023
@tertsdiepraam
Copy link
Member

Cool! Having two additional crates is a bit unfortunate, but if that is the best solution it's alright. I think the CI is failing because you didn't push changes to Cargo.lock.

@KrishnaNagam
Copy link
Author

Yeah! chrono v0.5 supposed to have a fix for this. will revisit this once v0.5 is released.
chronotope/chrono#970.

BTW, I have pushed the cargo.lock changes.

@KrishnaNagam
Copy link
Author

Still CI is failing.
I have enabled Github Actions in my repo to run these tests myself. I will come back once all tests are passed.

@tertsdiepraam
Copy link
Member

Yeah! chrono v0.5 supposed to have a fix for this.

While you're fixing the tests, it might be nice to add a comment with this info to the code.

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail-2/inotify-dir-recreate

@KrishnaNagam
Copy link
Author

Oops! I accidentally merged main branch again 😅
Now its waiting for CI 😳.

@@ -397,7 +406,7 @@ fn make_format_string(settings: &Settings) -> &str {
Rfc3339Format::Ns => "%F %T.%f%:z",
},
Format::Custom(ref fmt) => fmt,
Format::Default => "%c",
Format::Default => "%a %b %-d %X %Z %Y",
Copy link
Contributor

Choose a reason for hiding this comment

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

Layman's question: Will this not override any locales from LC_TIME we could use? That could be a blocker for #3143

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but this change doesn't make it any worse than then the current implementation 😄

Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/mv/dir2dir is no longer failing!
Skipping an intermittent issue tests/tail/inotify-dir-recreate

Comment on lines +276 to +278
let format_string = &format_string
.replace("%N", "%f")
.replace("%Z", tz_abbreviation);
Copy link
Member

Choose a reason for hiding this comment

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

This is not quite correct, because this means that %f should be escaped. Ultimately, we might need to completely customize this. I suppose it's good enough for now though.

Copy link
Author

Choose a reason for hiding this comment

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

Actually, this line of code was already there. Cargo fmt has put it in new line 😀. I am interested in solving this though in my next PR.

I didn't get why %f need to be escaped. Did you mean, if there is %f already within the input, it should be escaped?

@@ -397,7 +406,7 @@ fn make_format_string(settings: &Settings) -> &str {
Rfc3339Format::Ns => "%F %T.%f%:z",
},
Format::Custom(ref fmt) => fmt,
Format::Default => "%c",
Format::Default => "%a %b %-d %X %Z %Y",
Copy link
Member

Choose a reason for hiding this comment

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

Yes, but this change doesn't make it any worse than then the current implementation 😄

Copy link

github-actions bot commented Feb 2, 2024

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

"Mon Mar 27 08:30:00 2023\n\
Sat Apr 1 12:00:00 2023\n\
Sat Apr 15 18:30:00 2023\n",
"Mon Mar 27 08:30:00 UTC 2023\n\
Copy link
Author

Choose a reason for hiding this comment

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

@tertsdiepraam
I have updated test case test_date_from_stdin, to align with the fix.

Copy link

GNU testsuite comparison:

GNU test failed: tests/cksum/md5sum. tests/cksum/md5sum is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/cksum/sha1sum. tests/cksum/sha1sum is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/cp/same-file. tests/cp/same-file is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/factor/factor. tests/factor/factor is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/timeout/timeout is no longer failing!
GNU test failed: tests/cp/cross-dev-symlink. tests/cp/cross-dev-symlink is passing on 'main'. Maybe you have to rebase?

@KrishnaNagam
Copy link
Author

Is this PR good enough to merge?
Please let me know if any changes required.

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

Copy link

github-actions bot commented Dec 2, 2024

GNU testsuite comparison:

GNU test failed: tests/du/hard-link. tests/du/hard-link is passing on 'main'. Maybe you have to rebase?

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