Skip to content

date: fix -s UTC conversion losing timezone offset#10828

Merged
ChrisDryden merged 1 commit intouutils:mainfrom
yachi:fix-date-set-utc-conversion
Feb 14, 2026
Merged

date: fix -s UTC conversion losing timezone offset#10828
ChrisDryden merged 1 commit intouutils:mainfrom
yachi:fix-date-set-utc-conversion

Conversation

@yachi
Copy link
Contributor

@yachi yachi commented Feb 8, 2026

Fixes #10800

-s with -u reinterpreted wall-clock time as UTC, losing the timezone offset. Extracted the conversion into a helper to make it testable and fixed it to preserve the absolute instant.

@github-actions
Copy link

github-actions bot commented Feb 8, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/shuf/shuf-reservoir (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/sort/sort-stale-thread-mem (passes in this run but fails in the 'main' branch)


#[test]
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
fn test_date_set_utc_with_offset() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this actually tests anything, it just checks to see if the user is root and fails. Maybe it would be better to add a unit test for this for the conversion?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see there's other integration tests in here that use the -s flag, can you follow the format of those tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! Replaced the integration test with a unit test that verifies the conversion directly.

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/mv/mv-special-1. tests/mv/mv-special-1 is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/pr/bounded-memory is no longer failing!
Note: The gnu test tests/dd/no-allocate is now being skipped but was previously passing.

@yachi yachi force-pushed the fix-date-set-utc-conversion branch from d84e70b to b760fd7 Compare February 12, 2026 22:11
@yachi yachi marked this pull request as draft February 12, 2026 22:25
@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/tail/pipe-f. tests/tail/pipe-f is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/factor/t33 is no longer failing!
Congrats! The gnu test tests/factor/t34 is no longer failing!
Congrats! The gnu test tests/factor/t36 is no longer failing!
Note: The gnu test tests/pr/bounded-memory is now being skipped but was previously passing.
Congrats! The gnu test tests/printf/printf-surprise is now passing!

@yachi yachi force-pushed the fix-date-set-utc-conversion branch from b760fd7 to d460a72 Compare February 14, 2026 13:29
@yachi yachi marked this pull request as ready for review February 14, 2026 13:43
@yachi yachi requested a review from ChrisDryden February 14, 2026 13:44
@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/misc/io-errors. tests/misc/io-errors is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tail/symlink (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/factor/t34 is no longer failing!
Congrats! The gnu test tests/printf/printf-surprise is now passing!

@yachi yachi marked this pull request as draft February 14, 2026 14:00
@yachi yachi force-pushed the fix-date-set-utc-conversion branch from d460a72 to faa9945 Compare February 14, 2026 15:52
@yachi yachi marked this pull request as ready for review February 14, 2026 15:54
@ChrisDryden ChrisDryden merged commit def3956 into uutils:main Feb 14, 2026
154 of 157 checks passed
@ChrisDryden
Copy link
Collaborator

Thanks!

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.

date: -u -s "10:30 EST" sets wrong time

2 participants