I have been researching this question, but the answers I am finding are for C#, not F#. It looks like I need to use DateTime.Compare, but I was hoping for a native solution.
The purpose of the function (below) is to determine if the access time of one file is >= to a threshold value. The threshold value is the last access time with a number of days subtracted from the last access time.
days_old is passed into the function isFileStale along with the file name fn.
I am just puzzled as to why this function always returns false.
let isFileStale fn days_old =
let rc =
let currentTime = ((System.DateTime.Now).ToLocalTime())
let lastFileUsed = File.GetLastAccessTime(fn)
let timeSpan = new TimeSpan(days_old, 0, 0, 0, 0)
let fileDeleteThreshhold = lastFileUsed.Subtract(timeSpan)
if fileDeleteThreshhold >= lastFileUsed then
true
else
false
rc