Subject: Re: Cygwin DLL 3.2.0 (W10) Problem with touch (8.26) for old dates < 1970
From: Brian Inglis <[email-masked]>
To: [email-masked]
Date: Wed, 14 Apr 2021 09:25:05 -0600
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>

On 2021-04-14 04:36, akiki--- via Cygwin wrote:
> I encountered problems with the use of timestamps in cygwin.
> May be it's an old problem, I don't know, using essentially files "recently" created/modified.
> I want to say after 1970 No problem, but before ...
> To day:
> touch -m -t 190001011200.00 x gives touch: format de date « 190001011200.00 » incorrect
> touch -m -t 190101011200.00 x gives ok - with ls -l x:
> -rw-r--r-- 1 user group 0 1 janv. 1910 x
> touch used is well /bin/touch
> By comparison on Ubuntu 18 LTS
> touch -m -t 190001011200.00 x is correct
> I know, timestamps are managed differently in windows and linux.
> I see also with the new windows terminal with ubuntu
> On windows file, like /mnt/c/x (windows is mounted by linux)
> touch -m -t 190001011200.00 x ; echo $? gives
> 0 #No error but timestamp is set to 1970-01-01
> On linux file as ~/x, it's correct;
> So, which confidence to have with cygwin about files of timestamp 19xx before 1970.
> May be it's ok after 1901. The answer is NOT.
> touch -m -t 190101011200.00 x gives sometimes format de date incorrect
> In some windows directories and more problematic, for a same directory, I don't understand why.
> May be due to embedded mounts.
> I hope to have been clear enough.

What's your OS + version, Cygwin uname -srvmo, Windows filesystem (and 
underlying if networked), time zone?

Please repeat touch tests, followed by ls -glo and --full-time if required.

I have timestamped some historical documents and images with no problems.
Works just fine for me on current Windows, Cygwin, NTFS back to Windows limits:

$ for ((y=1980;y>1580;y-=10)); do touch -t ${y}12312359.59 t && ls -glo t || 
echo $y; done
-rw-r--r--+ 1 1 Dec 31  1980 t
-rw-r--r--+ 1 1 Dec 31  1970 t
-rw-r--r--+ 1 1 Dec 31  1960 t
-rw-r--r--+ 1 1 Dec 31  1950 t
-rw-r--r--+ 1 1 Dec 31  1940 t
-rw-r--r--+ 1 1 Dec 31  1930 t
-rw-r--r--+ 1 1 Dec 31  1920 t
-rw-r--r--+ 1 1 Dec 31  1910 t
-rw-r--r--+ 1 1 Dec 31  1900 t
-rw-r--r--+ 1 1 Dec 31  1890 t
-rw-r--r--+ 1 1 Dec 31  1880 t
-rw-r--r--+ 1 1 Dec 31  1870 t
-rw-r--r--+ 1 1 Dec 31  1860 t
-rw-r--r--+ 1 1 Dec 31  1850 t
-rw-r--r--+ 1 1 Dec 31  1840 t
-rw-r--r--+ 1 1 Dec 31  1830 t
-rw-r--r--+ 1 1 Dec 31  1820 t
-rw-r--r--+ 1 1 Dec 31  1810 t
-rw-r--r--+ 1 1 Dec 31  1800 t
-rw-r--r--+ 1 1 Dec 31  1790 t
-rw-r--r--+ 1 1 Dec 31  1780 t
-rw-r--r--+ 1 1 Dec 31  1770 t
-rw-r--r--+ 1 1 Dec 31  1760 t
-rw-r--r--+ 1 1 Dec 31  1750 t
-rw-r--r--+ 1 1 Dec 31  1740 t
-rw-r--r--+ 1 1 Dec 31  1730 t
-rw-r--r--+ 1 1 Dec 31  1720 t
-rw-r--r--+ 1 1 Dec 31  1710 t
-rw-r--r--+ 1 1 Dec 31  1700 t
-rw-r--r--+ 1 1 Dec 31  1690 t
-rw-r--r--+ 1 1 Dec 31  1680 t
-rw-r--r--+ 1 1 Dec 31  1670 t
-rw-r--r--+ 1 1 Dec 31  1660 t
-rw-r--r--+ 1 1 Dec 31  1650 t
-rw-r--r--+ 1 1 Dec 31  1640 t
-rw-r--r--+ 1 1 Dec 31  1630 t
-rw-r--r--+ 1 1 Dec 31  1620 t
-rw-r--r--+ 1 1 Dec 31  1610 t
-rw-r--r--+ 1 1 Dec 31  1600 t
touch: setting times of 't': Invalid argument
1590
$ for ((y=1600;y>1598;--y)); do touch -t ${y}12312359.59 t && ls -glo t || echo 
$y; done
-rw-r--r--+ 1 1 Dec 31  1600 t
touch: setting times of 't': Invalid argument
1599
$ y=1600; for ((m=12;m>10;--m)); do touch -t ${y}${m}312359.59 t && ls -glo t || 
echo $y-$m; done  -rw-r--r--+ 1 1 Dec 31  1600 t
touch: invalid date format ‘160011312359.59’
1600-11

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple