{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments/40244672","id":40244672,"diff_hunk":"@@ -0,0 +1,330 @@\n+- Feature Name: time_improvements\n+- Start Date: 2015-09-20\n+- RFC PR: (leave this empty)\n+- Rust Issue: (leave this empty)\n+\n+# Summary\n+\n+This RFC proposes several new types and associated APIs for working with times in Rust.\n+The primary new types are `ProcessTime`, for working with monotonic time within a single\n+process, and `SystemTime`, for working with times across processes on a single system\n+(usually internally represented as a number of seconds since an epoch).\n+\n+# Motivations\n+\n+The primary motivation of this RFC is to flesh out a larger set of APIs for\n+representing instants in time and durations of time.\n+\n+For various reasons that this RFC will explore, APIs related to time are fairly\n+error-prone and have a number of caveats that programmers do not expect.\n+\n+Rust APIs tend to expose more of these kinds of caveats through their APIs, in\n+order to help programmers become aware of and handle edge-cases. At the same\n+time, un-ergonomic APIs can work against that goal.\n+\n+This RFC attempts to balance the desire to expose common footguns and help\n+programmers handle edge-cases with a desire to avoid creating so many hoops to\n+jump through that the useful caveats get ignored.\n+\n+At a high level, this RFC covers two concepts related to time:\n+\n+* Instants, moments in time\n+* Durations, an amount of time between two instants\n+\n+We would like to be able to do some basic operations with these instants:\n+\n+* Compare two instants\n+* Add a time period to an instant\n+* Subtract a time period from an instant\n+* Compare an instant to \"now\" to discover time elapsed\n+\n+However, there are a number of problems that arise when trying to define these\n+types and operations.\n+\n+First of all, with the exception of instants created in the rutime of a single\n+process, instants are not monotonic. A simple example of this is that if a","path":"text/0000-time-improvements.md","position":45,"original_position":45,"commit_id":"95d180e76d7b0c9051a5d840519bd8cea3b3ad16","original_commit_id":"95d180e76d7b0c9051a5d840519bd8cea3b3ad16","user":{"login":"eternaleye","id":99404,"avatar_url":"https://avatars.githubusercontent.com/u/99404?v=3","gravatar_id":"","url":"https://api.github.com/users/eternaleye","html_url":"https://github.com/eternaleye","followers_url":"https://api.github.com/users/eternaleye/followers","following_url":"https://api.github.com/users/eternaleye/following{/other_user}","gists_url":"https://api.github.com/users/eternaleye/gists{/gist_id}","starred_url":"https://api.github.com/users/eternaleye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eternaleye/subscriptions","organizations_url":"https://api.github.com/users/eternaleye/orgs","repos_url":"https://api.github.com/users/eternaleye/repos","events_url":"https://api.github.com/users/eternaleye/events{/privacy}","received_events_url":"https://api.github.com/users/eternaleye/received_events","type":"User","site_admin":false},"body":"There's also that there are multiple _kinds_ of monotonic time on some systems.\r\n\r\nIn particular, while CLOCK_MONOTONIC generates comparable and orderable _instants_, it does not generate comparable _durations_ because it is still affected by NTP's ability to alter the length of a second. Linux at least has CLOCK_MONOTONIC_RAW (whose ticks are of constant length), but _it_ makes no guarantee of the relationship between its units and human-meaningful ones.\r\n\r\nIn addition, suspend/hibernate is not counted for CLOCK_MONOTONIC, so durations from it are even more suspect - but Linux has the (underdocumented) CLOCK_BOOTTIME, which does count that... but isn't clear what its guarantees on the length of a tick are (consistent vs. meaningful).","created_at":"2015-09-23T19:12:22Z","updated_at":"2015-09-23T19:12:22Z","html_url":"https://github.com/rust-lang/rfcs/pull/1288#discussion_r40244672","pull_request_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/1288","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments/40244672"},"html":{"href":"https://github.com/rust-lang/rfcs/pull/1288#discussion_r40244672"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/1288"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/1288","id":45514269,"html_url":"https://github.com/rust-lang/rfcs/pull/1288","diff_url":"https://github.com/rust-lang/rfcs/pull/1288.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/1288.patch","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1288","number":1288,"state":"open","locked":false,"title":"Improvements to the Time APIs","user":{"login":"wycats","id":4,"avatar_url":"https://avatars.githubusercontent.com/u/4?v=3","gravatar_id":"","url":"https://api.github.com/users/wycats","html_url":"https://github.com/wycats","followers_url":"https://api.github.com/users/wycats/followers","following_url":"https://api.github.com/users/wycats/following{/other_user}","gists_url":"https://api.github.com/users/wycats/gists{/gist_id}","starred_url":"https://api.github.com/users/wycats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wycats/subscriptions","organizations_url":"https://api.github.com/users/wycats/orgs","repos_url":"https://api.github.com/users/wycats/repos","events_url":"https://api.github.com/users/wycats/events{/privacy}","received_events_url":"https://api.github.com/users/wycats/received_events","type":"User","site_admin":false},"body":"[Rendered](https://github.com/wycats/rfcs/blob/time-improvements/text/0000-time-improvements.md)","created_at":"2015-09-21T04:50:25Z","updated_at":"2015-09-23T19:12:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c4d80f2cb5277c6fef7f6bdf034873afc3f9663","assignee":{"login":"wycats","id":4,"avatar_url":"https://avatars.githubusercontent.com/u/4?v=3","gravatar_id":"","url":"https://api.github.com/users/wycats","html_url":"https://github.com/wycats","followers_url":"https://api.github.com/users/wycats/followers","following_url":"https://api.github.com/users/wycats/following{/other_user}","gists_url":"https://api.github.com/users/wycats/gists{/gist_id}","starred_url":"https://api.github.com/users/wycats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wycats/subscriptions","organizations_url":"https://api.github.com/users/wycats/orgs","repos_url":"https://api.github.com/users/wycats/repos","events_url":"https://api.github.com/users/wycats/events{/privacy}","received_events_url":"https://api.github.com/users/wycats/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/1288/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/1288/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1288/comments","statuses_url":"https://api.github.com/repos/rust-lang/rfcs/statuses/95d180e76d7b0c9051a5d840519bd8cea3b3ad16","head":{"label":"wycats:time-improvements","ref":"time-improvements","sha":"95d180e76d7b0c9051a5d840519bd8cea3b3ad16","user":{"login":"wycats","id":4,"avatar_url":"https://avatars.githubusercontent.com/u/4?v=3","gravatar_id":"","url":"https://api.github.com/users/wycats","html_url":"https://github.com/wycats","followers_url":"https://api.github.com/users/wycats/followers","following_url":"https://api.github.com/users/wycats/following{/other_user}","gists_url":"https://api.github.com/users/wycats/gists{/gist_id}","starred_url":"https://api.github.com/users/wycats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wycats/subscriptions","organizations_url":"https://api.github.com/users/wycats/orgs","repos_url":"https://api.github.com/users/wycats/repos","events_url":"https://api.github.com/users/wycats/events{/privacy}","received_events_url":"https://api.github.com/users/wycats/received_events","type":"User","site_admin":false},"repo":{"id":29898397,"name":"rfcs","full_name":"wycats/rfcs","owner":{"login":"wycats","id":4,"avatar_url":"https://avatars.githubusercontent.com/u/4?v=3","gravatar_id":"","url":"https://api.github.com/users/wycats","html_url":"https://github.com/wycats","followers_url":"https://api.github.com/users/wycats/followers","following_url":"https://api.github.com/users/wycats/following{/other_user}","gists_url":"https://api.github.com/users/wycats/gists{/gist_id}","starred_url":"https://api.github.com/users/wycats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wycats/subscriptions","organizations_url":"https://api.github.com/users/wycats/orgs","repos_url":"https://api.github.com/users/wycats/repos","events_url":"https://api.github.com/users/wycats/events{/privacy}","received_events_url":"https://api.github.com/users/wycats/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wycats/rfcs","description":"RFCs for changes to Rust","fork":true,"url":"https://api.github.com/repos/wycats/rfcs","forks_url":"https://api.github.com/repos/wycats/rfcs/forks","keys_url":"https://api.github.com/repos/wycats/rfcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wycats/rfcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wycats/rfcs/teams","hooks_url":"https://api.github.com/repos/wycats/rfcs/hooks","issue_events_url":"https://api.github.com/repos/wycats/rfcs/issues/events{/number}","events_url":"https://api.github.com/repos/wycats/rfcs/events","assignees_url":"https://api.github.com/repos/wycats/rfcs/assignees{/user}","branches_url":"https://api.github.com/repos/wycats/rfcs/branches{/branch}","tags_url":"https://api.github.com/repos/wycats/rfcs/tags","blobs_url":"https://api.github.com/repos/wycats/rfcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wycats/rfcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wycats/rfcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/wycats/rfcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wycats/rfcs/statuses/{sha}","languages_url":"https://api.github.com/repos/wycats/rfcs/languages","stargazers_url":"https://api.github.com/repos/wycats/rfcs/stargazers","contributors_url":"https://api.github.com/repos/wycats/rfcs/contributors","subscribers_url":"https://api.github.com/repos/wycats/rfcs/subscribers","subscription_url":"https://api.github.com/repos/wycats/rfcs/subscription","commits_url":"https://api.github.com/repos/wycats/rfcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/wycats/rfcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/wycats/rfcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/wycats/rfcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/wycats/rfcs/contents/{+path}","compare_url":"https://api.github.com/repos/wycats/rfcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wycats/rfcs/merges","archive_url":"https://api.github.com/repos/wycats/rfcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wycats/rfcs/downloads","issues_url":"https://api.github.com/repos/wycats/rfcs/issues{/number}","pulls_url":"https://api.github.com/repos/wycats/rfcs/pulls{/number}","milestones_url":"https://api.github.com/repos/wycats/rfcs/milestones{/number}","notifications_url":"https://api.github.com/repos/wycats/rfcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wycats/rfcs/labels{/name}","releases_url":"https://api.github.com/repos/wycats/rfcs/releases{/id}","created_at":"2015-01-27T05:08:24Z","updated_at":"2015-04-06T20:45:09Z","pushed_at":"2015-09-22T15:34:57Z","git_url":"git://github.com/wycats/rfcs.git","ssh_url":"git@github.com:wycats/rfcs.git","clone_url":"https://github.com/wycats/rfcs.git","svn_url":"https://github.com/wycats/rfcs","homepage":"","size":1751,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"0599646a7c27ade60927bf9ac1f63c028a1523d9","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":17527989,"name":"rfcs","full_name":"rust-lang/rfcs","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/rfcs","description":"RFCs for changes to Rust","fork":false,"url":"https://api.github.com/repos/rust-lang/rfcs","forks_url":"https://api.github.com/repos/rust-lang/rfcs/forks","keys_url":"https://api.github.com/repos/rust-lang/rfcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rfcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rfcs/teams","hooks_url":"https://api.github.com/repos/rust-lang/rfcs/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rfcs/events","assignees_url":"https://api.github.com/repos/rust-lang/rfcs/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rfcs/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rfcs/tags","blobs_url":"https://api.github.com/repos/rust-lang/rfcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rfcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rfcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rfcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rfcs/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rfcs/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rfcs/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rfcs/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rfcs/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rfcs/subscription","commits_url":"https://api.github.com/repos/rust-lang/rfcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rfcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rfcs/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rfcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rfcs/merges","archive_url":"https://api.github.com/repos/rust-lang/rfcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rfcs/downloads","issues_url":"https://api.github.com/repos/rust-lang/rfcs/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rfcs/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rfcs/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rfcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rfcs/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rfcs/releases{/id}","created_at":"2014-03-07T21:29:00Z","updated_at":"2015-09-23T16:07:50Z","pushed_at":"2015-09-23T03:52:47Z","git_url":"git://github.com/rust-lang/rfcs.git","ssh_url":"git@github.com:rust-lang/rfcs.git","clone_url":"https://github.com/rust-lang/rfcs.git","svn_url":"https://github.com/rust-lang/rfcs","homepage":"","size":10681,"stargazers_count":461,"watchers_count":461,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":233,"mirror_url":null,"open_issues_count":551,"forks":233,"open_issues":551,"watchers":461,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/1288"},"html":{"href":"https://github.com/rust-lang/rfcs/pull/1288"},"issue":{"href":"https://api.github.com/repos/rust-lang/rfcs/issues/1288"},"comments":{"href":"https://api.github.com/repos/rust-lang/rfcs/issues/1288/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/1288/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rfcs/pulls/1288/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rfcs/statuses/95d180e76d7b0c9051a5d840519bd8cea3b3ad16"}}}}