Problem if LastWrite date is older than 12/14/1901

Advertisement

NottaSmartMan
Joined:
Posts:
43

Problem if LastWrite date is older than 12/14/1901

I'm having an odd problem and am finding it difficult to determine if the issue is WinSCP, the servers I'm connecting to, or perhaps the SFTP standard itself.

I have several thousand files I need to replicate where the LastWrite timestamp is 1/1/1601 (oldest possible NTFS timestamp).

I've tried various clients (WinSCP, FileZilla, Native Windows) and servers (Cerberus, Bitvise, Rebex tiny sFTP), and haven't found any combination that will allow for old remote timestamps to set and display properly.

This issue is causing thousands of files to re-sync (via $session.SynchronizeDirectories) whenever our script is re-ran because WinSCP interprets a 1/1/1601 timestamp as 4/22/2009.

For a sanity check, to your knowledge, does the SFTP protocol permit setting and listing dates older than 1901 in the spec? If so, should WinSCP be able to set and understand such an old date if the server is sending such a timestamp properly in a directory listing?

Attached is a screenshot to hopefully better illustrate my point... you'll see that the files with timestamps pre 12/14/1901 locally differ wildly from their remote counterpart.
  • timestampissue.png (120.17 KB, Private file)

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,541
Location:
Prague, Czechia

Re: Problem if LastWrite date is older than 12/14/1901

The most common SFTP version 3 uses 32-bit unsigned Unix timestamps. So it does not support dates before 1970. The newer versions of the protocol support 64-bit signed timestamps, so virtually unlimited date range.

Reply with quote

NottaSmartMan
Joined:
Posts:
43

What's confusing me is that I'm able to set/read remote dates as early as 1901. So, I'm able to get beyond 1970.

My logs show "SFTP version 6 negotiated."

Does WinSCP itself support setting/reading such old remote dates (year 1601)? My logs don't show the date read or attempted to be set on either side.

Reply with quote

Advertisement

You can post new topics in this forum