-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix touch -t with 2 digit years when YY > 68 #7378
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
Conversation
I'm fairly new to rust, so I'm sure it can be improved. Otherwise I've quite a bit of experience under my belt as a maintainer myself, so you can stay terse in your requests and explanations, I know time can be precious. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR fixes the logic for interpreting 2-digit years in the touch command, aligning its behavior with GNU touch.
- Introduces a helper function to prepend "19" or "20" to 2-digit year strings based on their value.
- Updates the timestamp parsing logic to utilize the new helper function.
- Adds tests to verify correct behavior for both 2-digit year ranges.
Reviewed Changes
File | Description |
---|---|
src/uu/touch/src/touch.rs | New helper function for determining century based on a 2-digit year is added and integrated into the timestamp parser. |
tests/by-util/test_touch.rs | Added tests to confirm that 2-digit years are correctly interpreted as 20xx or 19xx based on their value. |
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
4588d36
to
15d3cdc
Compare
GNU testsuite comparison:
|
One of the failure:
The difference in seconds is exactly |
(workflows need approval after the recent force-push) |
for what it is worth, I think gnu touch behaviors comes from gnulib's parse-datetime.y |
It's unclear to me how the failure seen in uutils#7378 is related to the change in the PR, it just happen that the test need to try touching in 2068. The 2^32 error in the test makes me strongly think of the year 2038 bug, so I added a test for that.
It's unclear to me how the failure seen in uutils#7378 is related to the change in the PR, it just happen that the test need to try touching in 2068. The 2^32 error in the test makes me strongly think of the year 2038 bug, so I added a test for that.
It's unclear to me how the failure seen in uutils#7378 is related to the change in the PR, it just happen that the test need to try touching in 2068. The 2^32 error in the test makes me strongly think of the year 2038 bug, so I added a test for that.
It's unclear to me how the failure seen in uutils#7378 is related to the change in the PR, it just happen that the test need to try touching in 2068. The 2^32 error in the test makes me strongly think of the year 2038 bug, so I added a test for that.
Failures seem to be read y2038 bug (see #7399), but I don't know if this bug should be ignored, or fixed on relevant platform, and which/if |
|
GNU testsuite comparison:
|
It's unclear to me how the failure seen in uutils#7378 is related to the change in the PR, it just happen that the test need to try touching in 2068. The 2^32 error in the test makes me strongly think of the year 2038 bug, so I added a test for that.
It's unclear to me how the failure seen in uutils#7378 is related to the change in the PR, it just happen that the test need to try touching in 2068. The 2^32 error in the test makes me strongly think of the year 2038 bug, so I added a test for that.
When using `touch -t` with a 2 digit year, the year is interpreted as a relative year to 2000. When the year is 68 or less, it should be interpreted as 20xx. When the year is 69 or more, it should be interpreted as 19xx. This is the behavior of GNU `touch`. fixes uutilsgh-7280 Arguably 2 digits years should be deprecated as we are already closer to 2069, than 1969.
It's unclear to me how the failure seen in uutils#7378 is related to the change in the PR, it just happen that the test need to try touching in 2068. The 2^32 error in the test makes me strongly think of the year 2038 bug, so I added a test for that.
It's unclear to me how the failure seen in uutils#7378 is related to the change in the PR, it just happen that the test need to try touching in 2068. The 2^32 error in the test makes me strongly think of the year 2038 bug, so I added a test for that.
When using
touch -t
with a 2 digit year, the year is interpreted as a relative year to 2000.When the year is 68 or less, it should be interpreted as 20xx. When the year is 69 or more, it should be interpreted as 19xx.
This is the behavior of GNU
touch
.fixes gh-7280
Arguably 2 digits years should be deprecated as we are already closer to 2069, than 1969.