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

touch: -t YYMMDDhhmm leads to incorrect year if YY > 68 #7280

Open
cakebaker opened this issue Feb 7, 2025 · 2 comments
Open

touch: -t YYMMDDhhmm leads to incorrect year if YY > 68 #7280

cakebaker opened this issue Feb 7, 2025 · 2 comments

Comments

@cakebaker
Copy link
Contributor

If a two-digit year is specified with -t, GNU touch uses the 19-prefix if the year is greater than 68, whereas uutils touch uses 20.

$ touch -t 6801010000 a
$ ls -l a
-rw-r--r-- 1 dho dho 0 Jan  1  2068 a
$ touch -t 6901010000 a
$ ls -l a
-rw-r--r-- 1 dho dho 0 Jan  1  1969 a


$ cargo run -q touch -t 6801010000 a
$ ls -l a
-rw-r--r-- 1 dho dho 0 Jan  1  2068 a
$ cargo run -q touch -t 6901010000 a
$ ls -l a
-rw-r--r-- 1 dho dho 0 Jan  1  2069 a
@RenjiSann
Copy link
Collaborator

That's a very specific issue there 🧐

I'm curious of why did GNU decided to change the behavior between 68-69 specifically

@cakebaker
Copy link
Contributor Author

I don't know what the reason is but the behavior is documented:

If the year is specified with only two digits, then cc is 20 for years in the range 0 … 68, and 19 for years in 69 … 99.

My guess is that it is related to its obsolete syntax:

[...] if there are two or more files and the first file is of the form ‘mmddhhmm[yy]’ and this would be a valid argument to the -t option (if the yy, if any, were moved to the front), and if the represented year is in the range 1969–1999, that argument is interpreted as the time for the other files instead of as a file name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants