-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
DateTime.ToFileTime
When you want to denote an unknown date in .NET, you normally use DateTime.MinValue or default(DateTime).
The equality for a FileTime is 0 (See WIN32_FILE_ATTRIBUTE_DATA structure)
But, if you try to use DateTime.ToFileTime(DateTime.MinValue) you get an ArgumentOutOfRangeException.
My suggestion is to make DateTime.ToFileTime to returns 0 if it gets DateTime.MinValue as input.
DateTime.FromFileTimes
Even in the opposite situation, when you want to use DateTime.FromFileTime, have an issue as I see it. If the FileTime is 0, it returns new DateTime(1601, 1, 1, 1, 0, 0). It is not entirely wrong, and is manageable. But I think it is semantically wrong when it returns something that looks like a specific date. I suggest that it returns DateTime.MinValue if it gets 0 as input.
That is an braking change, but I see it as acceptable when I do not think that this special case is not so common