coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

date: improve timezone handling and UTC mode support

Open jadijadi opened this issue 9 months ago • 14 comments

  • Add proper UTC mode handling with -u flag
  • Improve TZ environment variable support
  • Add more TZ tests

FIXES #7497 FIXES #7498

jadijadi avatar Mar 28 '25 00:03 jadijadi

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Mar 28 '25 01:03 github-actions[bot]

Can you please run cargo clippy? The corresponding checks fail in the CI :|

cakebaker avatar Mar 28 '25 09:03 cakebaker

Can you please run cargo clippy? The corresponding checks fail in the CI :|

Done and Thanks.

jadijadi avatar Mar 28 '25 16:03 jadijadi

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Mar 28 '25 16:03 github-actions[bot]

Side note: it seems our cargo fmt disagree on some minor stuff. I'm on +stable.

jadijadi avatar Apr 01 '25 01:04 jadijadi

GNU testsuite comparison:

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

github-actions[bot] avatar Apr 01 '25 02:04 github-actions[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Apr 01 '25 03:04 github-actions[bot]

@jadijadi looking at this a bit more... I feel like this would be better fixed in chrono, not here (I was looking at #7504 and couldn't really fully grasp why uucore handling code needs to be so complicated...).

See https://github.com/chronotope/chrono/issues/1690 . If you're interested to submit a patch for chrono I'm happy to leave it to you, just let me know.

If we have problems getting this fix into chrono (or if getting a new release takes time), we could think of some wrapper in uucore that fixes this for all the apps that handle dates (not just date, but also ls and du).

drinkcat avatar Apr 05 '25 13:04 drinkcat

Argh, maybe I'm wrong, I think we still need some custom logic to handle timezone passed in TZ (i.e. to be able to read the abbreviation from the timezone database).

But... I think we can make things easier by having a wrapper function that returns something like this:

date.with_timezone(&tz)

(where tz comes from the code we already have in timezone_abbreviation)

drinkcat avatar Apr 05 '25 13:04 drinkcat

@jadijadi are you still working on it ? thanks :)

sylvestre avatar Apr 17 '25 19:04 sylvestre

(btw the empty TZ case is fixed in chrono, but we need to wait for a new release: https://github.com/chronotope/chrono/pull/1691)

drinkcat avatar Apr 17 '25 20:04 drinkcat

@jadijadi are you still working on it ? thanks :)

yes. had a busy week. will work on it during this long weekend

jadijadi avatar Apr 18 '25 20:04 jadijadi

waiting for update

I'm a bit lost on this. As @drinkcat mentioned, its better to have most of these fixes in chrono. And they are already fixed there. So maybe its better to close this PR and wait for chrono changes to be merged and work on this again based on what they have.

I'm still having busy work days and wont have time to go deeper and see what is changed in upcomming days. If anyone else wants to finish this, I will be happy.

jadijadi avatar Apr 23 '25 00:04 jadijadi

I... also lost all context... and if it's not clear from my comments, I was also a bit confused a few weeks ago when I tried to look at this ,-)

  • I pinged chrono maintainer here: https://github.com/chronotope/chrono/pull/1691, would be good to at least have the empty TZ covered.
  • I'll resume my efforts on #7504, hopefully in the process I'll understand better what needs to be done here (I think it's technically orthogonal, but some of the refactoring will probably conflict with this PR)

drinkcat avatar Apr 23 '25 13:04 drinkcat

I will close this because most fixed are already done in https://github.com/chronotope/chrono/pull/1691 . Will open another PR if I work on the remaining issues.

jadijadi avatar Jun 10 '25 23:06 jadijadi