date: fix %Z specifier does not print TZ abbr#5164
date: fix %Z specifier does not print TZ abbr#5164KrishnaNagam wants to merge 24 commits intouutils:mainfrom
Conversation
|
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. |
|
Yeah! chrono v0.5 supposed to have a fix for this. will revisit this once v0.5 is released. BTW, I have pushed the cargo.lock changes. |
|
Still CI is failing. |
While you're fixing the tests, it might be nice to add a comment with this info to the code. |
|
GNU testsuite comparison: |
|
Oops! I accidentally merged main branch again 😅 |
src/uu/date/src/date.rs
Outdated
| }, | ||
| Format::Custom(ref fmt) => fmt, | ||
| Format::Default => "%c", | ||
| Format::Default => "%a %b %-d %X %Z %Y", |
There was a problem hiding this comment.
Layman's question: Will this not override any locales from LC_TIME we could use? That could be a blocker for #3143
There was a problem hiding this comment.
Yes, but this change doesn't make it any worse than then the current implementation 😄
|
GNU testsuite comparison: |
| let format_string = &format_string | ||
| .replace("%N", "%f") | ||
| .replace("%Z", tz_abbreviation); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
src/uu/date/src/date.rs
Outdated
| }, | ||
| Format::Custom(ref fmt) => fmt, | ||
| Format::Default => "%c", | ||
| Format::Default => "%a %b %-d %X %Z %Y", |
There was a problem hiding this comment.
Yes, but this change doesn't make it any worse than then the current implementation 😄
|
GNU testsuite comparison: |
added space padding for day in default format
fix Cargo.lock
| "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\ |
There was a problem hiding this comment.
@tertsdiepraam
I have updated test case test_date_from_stdin, to align with the fix.
|
GNU testsuite comparison: |
|
Is this PR good enough to merge? |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
|
Closing this PR as the changes have been included in #7134 @KrishnaNagam thanks for your PR! |
fixes issue #3756 for date util
description:
chronocrate ignores %Z specifier. only prints timezone offset. added crateschrono-tzandiana_time_zoneto calculate the timezone abbreviation and replace %Z specifier with the the abbreviation.