{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/6186","repository_url":"https://api.github.com/repos/dotnet/coreclr","labels_url":"https://api.github.com/repos/dotnet/coreclr/issues/6186/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/6186/comments","events_url":"https://api.github.com/repos/dotnet/coreclr/issues/6186/events","html_url":"https://github.com/dotnet/coreclr/issues/6186","id":164512315,"number":6186,"title":"Make ToFileTime understand DateTime.MinValue","user":{"login":"magol","id":493140,"avatar_url":"https://avatars.githubusercontent.com/u/493140?v=3","gravatar_id":"","url":"https://api.github.com/users/magol","html_url":"https://github.com/magol","followers_url":"https://api.github.com/users/magol/followers","following_url":"https://api.github.com/users/magol/following{/other_user}","gists_url":"https://api.github.com/users/magol/gists{/gist_id}","starred_url":"https://api.github.com/users/magol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magol/subscriptions","organizations_url":"https://api.github.com/users/magol/orgs","repos_url":"https://api.github.com/users/magol/repos","events_url":"https://api.github.com/users/magol/events{/privacy}","received_events_url":"https://api.github.com/users/magol/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/coreclr/labels/mscorlib","name":"mscorlib","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-08T11:31:51Z","updated_at":"2016-07-15T21:09:21Z","closed_at":null,"body":"[DateTime.ToFileTime](https://msdn.microsoft.com/en-us/library/system.datetime.tofiletime(v=vs.110).aspx)\r\n---------------------------\r\nWhen you want to denote an unknown date in .NET, you normally use `DateTime.MinValue` or `default(DateTime)`.\r\nThe equality for a FileTime is `0` (See [WIN32_FILE_ATTRIBUTE_DATA structure](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365739(v=vs.85).aspx)) \r\n\r\nBut, if you try to use `DateTime.ToFileTime(DateTime.MinValue)` you get an `ArgumentOutOfRangeException`. \r\n\r\nMy suggestion is to make `DateTime.ToFileTime` to returns `0` if it gets `DateTime.MinValue` as input.\r\n\r\n[DateTime.FromFileTimes](https://msdn.microsoft.com/en-us/library/system.datetime.fromfiletime(v=vs.110).aspx)\r\n-------------------------------\r\nEven 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.\r\nThat is an braking change, but I see it as acceptable when I do not think that this special case is not so common"},"comment":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/comments/233070649","html_url":"https://github.com/dotnet/coreclr/issues/6186#issuecomment-233070649","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/6186","id":233070649,"user":{"login":"magol","id":493140,"avatar_url":"https://avatars.githubusercontent.com/u/493140?v=3","gravatar_id":"","url":"https://api.github.com/users/magol","html_url":"https://github.com/magol","followers_url":"https://api.github.com/users/magol/followers","following_url":"https://api.github.com/users/magol/following{/other_user}","gists_url":"https://api.github.com/users/magol/gists{/gist_id}","starred_url":"https://api.github.com/users/magol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magol/subscriptions","organizations_url":"https://api.github.com/users/magol/orgs","repos_url":"https://api.github.com/users/magol/repos","events_url":"https://api.github.com/users/magol/events{/privacy}","received_events_url":"https://api.github.com/users/magol/received_events","type":"User","site_admin":false},"created_at":"2016-07-15T21:09:21Z","updated_at":"2016-07-15T21:09:21Z","body":"It is true that `DateTime.MinValue` is a known date.\r\nBut it is also true that `DateTime.MinValue == default(DateTime)` so also an uninitialized `DateTime` have this value.\r\nPurely pragmatic one can consider it as an uninitialized value. But you're right, it must be correct."}}
{"actor":{"display_login":"magol"}}