{"action":"created","issue":{"url":"https://api.github.com/repos/moment/moment/issues/1794","labels_url":"https://api.github.com/repos/moment/moment/issues/1794/labels{/name}","comments_url":"https://api.github.com/repos/moment/moment/issues/1794/comments","events_url":"https://api.github.com/repos/moment/moment/issues/1794/events","html_url":"https://github.com/moment/moment/pull/1794","id":38591058,"number":1794,"title":"Feature - Round to a unit by a given offset","user":{"login":"triqi","id":2232035,"avatar_url":"https://avatars.githubusercontent.com/u/2232035?v=3","gravatar_id":"","url":"https://api.github.com/users/triqi","html_url":"https://github.com/triqi","followers_url":"https://api.github.com/users/triqi/followers","following_url":"https://api.github.com/users/triqi/following{/other_user}","gists_url":"https://api.github.com/users/triqi/gists{/gist_id}","starred_url":"https://api.github.com/users/triqi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/triqi/subscriptions","organizations_url":"https://api.github.com/users/triqi/orgs","repos_url":"https://api.github.com/users/triqi/repos","events_url":"https://api.github.com/users/triqi/events{/privacy}","received_events_url":"https://api.github.com/users/triqi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/moment/moment/labels/New+Feature","name":"New Feature","color":"bfe5bf"},{"url":"https://api.github.com/repos/moment/moment/labels/todo","name":"todo","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/moment/moment/milestones/21","labels_url":"https://api.github.com/repos/moment/moment/milestones/21/labels","id":938927,"number":21,"title":"2.10","description":"","creator":{"login":"ichernev","id":757060,"avatar_url":"https://avatars.githubusercontent.com/u/757060?v=3","gravatar_id":"","url":"https://api.github.com/users/ichernev","html_url":"https://github.com/ichernev","followers_url":"https://api.github.com/users/ichernev/followers","following_url":"https://api.github.com/users/ichernev/following{/other_user}","gists_url":"https://api.github.com/users/ichernev/gists{/gist_id}","starred_url":"https://api.github.com/users/ichernev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ichernev/subscriptions","organizations_url":"https://api.github.com/users/ichernev/orgs","repos_url":"https://api.github.com/users/ichernev/repos","events_url":"https://api.github.com/users/ichernev/events{/privacy}","received_events_url":"https://api.github.com/users/ichernev/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":0,"state":"open","created_at":"2015-01-16T17:43:52Z","updated_at":"2015-01-17T10:02:25Z","due_on":null,"closed_at":null},"comments":27,"created_at":"2014-07-24T01:53:19Z","updated_at":"2015-01-17T10:20:45Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/moment/moment/pulls/1794","html_url":"https://github.com/moment/moment/pull/1794","diff_url":"https://github.com/moment/moment/pull/1794.diff","patch_url":"https://github.com/moment/moment/pull/1794.patch"},"body":"Round up, down or to the nearest unit.\r\n\r\nUsage: moment.roundTo(units, [offset, midpoint])\r\n\r\nm.roundTo('minute', 15); // Round the moment to the nearest 15 minutes.\r\nm.roundTo('minute', 15, 'up'); // Round the moment up to the nearest 15 minutes.\r\nm.roundTo('minute', 15, 'down'); // Round the moment down to the nearest 15 minutes."},"comment":{"url":"https://api.github.com/repos/moment/moment/issues/comments/70361861","html_url":"https://github.com/moment/moment/pull/1794#issuecomment-70361861","issue_url":"https://api.github.com/repos/moment/moment/issues/1794","id":70361861,"user":{"login":"ichernev","id":757060,"avatar_url":"https://avatars.githubusercontent.com/u/757060?v=3","gravatar_id":"","url":"https://api.github.com/users/ichernev","html_url":"https://github.com/ichernev","followers_url":"https://api.github.com/users/ichernev/followers","following_url":"https://api.github.com/users/ichernev/following{/other_user}","gists_url":"https://api.github.com/users/ichernev/gists{/gist_id}","starred_url":"https://api.github.com/users/ichernev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ichernev/subscriptions","organizations_url":"https://api.github.com/users/ichernev/orgs","repos_url":"https://api.github.com/users/ichernev/repos","events_url":"https://api.github.com/users/ichernev/events{/privacy}","received_events_url":"https://api.github.com/users/ichernev/received_events","type":"User","site_admin":false},"created_at":"2015-01-17T10:20:45Z","updated_at":"2015-01-17T10:20:45Z","body":"I'll look into this, but for sure:\r\n* `roundTo(value, unit, 'up' | 'down')` (reorder first two args)\r\n* zero out smaller units\r\n* if your round up across higher boundary -- make it 0 (like `5:55` minutes, `roundTo(7, 'minutes', 'up')` should give `6:00`). If we do 6:03 (63 minutes after 5), then another `roundTo` with the same arguments would change it further (as if it wasn't rounded the first time).\r\n* if you round with big values (like 90 minutes), round to higher unit (like hour in this case). There are too many interpretations and cases for this to work well otherwise."}}