1

Microsoft's Robocopy program has these two options:

/FFT :: assume FAT File Times (2-second granularity).

/DST :: compensate for one-hour DST time differences.

What is the exact algorithm that Robocopy uses for this?

If I wanted to implement this in Python for example, how would I do this? I would like to know specifically how Robocopy does it, and I would like to know if there is a more correct way to compare timestamps while allowing for DST and filesystem differences.

def compare_file_timestamps_robocopy_style(file1, file2):
    """Returns True if the file timestamps should be considered equal when
    adjusted for filesystem granularity and daylight savings time.
    
    This uses the same algorithm as Microsoft's Robocopy.
    """
    time1 = os.path.getmtime(file1)
    time2 = os.path.getmtime(file2)
    return ???

A pseudocode answer would be ok too if it is detailed enough.

2
  • I don't know what the /DST flag does, so I can't answer directly. But I do know that FAT and its variants use local-time for timestamps, whereas NTFS and most other modern files systems use UTC-based timestamps. That creates issues often on portable devices such as memory sticks of digital cameras. In the case of ambiguous local time in a DST fall-back, the only way to disambiguate would be through some other piece of data, such as a sequentially generated filename, presuming there are files in both the daylight and standard periods and they are out of sequence. Maybe it's doing that? IDK Commented Aug 4 at 15:06
  • FWIW, ChatGPT speculates that /DST would be implemented such that two files with timestamps exactly one hour apart would be treated as if the timestamps matched. That makes sense to me also - but I cannot find that documented anywhere. It's also hacky as F. Commented Aug 4 at 15:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.