{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/16647","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/16647/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/16647/comments","events_url":"https://api.github.com/repos/golang/go/issues/16647/events","html_url":"https://github.com/golang/go/issues/16647","id":170237905,"number":16647,"title":"time: Truncate example invalid","user":{"login":"quentinmit","id":115761,"avatar_url":"https://avatars.githubusercontent.com/u/115761?v=3","gravatar_id":"","url":"https://api.github.com/users/quentinmit","html_url":"https://github.com/quentinmit","followers_url":"https://api.github.com/users/quentinmit/followers","following_url":"https://api.github.com/users/quentinmit/following{/other_user}","gists_url":"https://api.github.com/users/quentinmit/gists{/gist_id}","starred_url":"https://api.github.com/users/quentinmit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quentinmit/subscriptions","organizations_url":"https://api.github.com/users/quentinmit/orgs","repos_url":"https://api.github.com/users/quentinmit/repos","events_url":"https://api.github.com/users/quentinmit/events{/privacy}","received_events_url":"https://api.github.com/users/quentinmit/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/golang/go/labels/Documentation","name":"Documentation","color":"aaffaa"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/38","html_url":"https://github.com/golang/go/milestones/Go1.8","labels_url":"https://api.github.com/repos/golang/go/milestones/38/labels","id":1709363,"number":38,"title":"Go1.8","description":"","creator":{"login":"griesemer","id":8528975,"avatar_url":"https://avatars.githubusercontent.com/u/8528975?v=3","gravatar_id":"","url":"https://api.github.com/users/griesemer","html_url":"https://github.com/griesemer","followers_url":"https://api.github.com/users/griesemer/followers","following_url":"https://api.github.com/users/griesemer/following{/other_user}","gists_url":"https://api.github.com/users/griesemer/gists{/gist_id}","starred_url":"https://api.github.com/users/griesemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/griesemer/subscriptions","organizations_url":"https://api.github.com/users/griesemer/orgs","repos_url":"https://api.github.com/users/griesemer/repos","events_url":"https://api.github.com/users/griesemer/events{/privacy}","received_events_url":"https://api.github.com/users/griesemer/received_events","type":"User","site_admin":false},"open_issues":467,"closed_issues":158,"state":"open","created_at":"2016-04-15T16:30:23Z","updated_at":"2016-09-07T20:08:26Z","due_on":"2017-02-01T08:00:00Z","closed_at":null},"comments":13,"created_at":"2016-08-09T18:31:30Z","updated_at":"2016-09-07T22:16:36Z","closed_at":null,"body":"The example for time.Time.Truncate suggests truncating by time.Hour, but in fact Truncate does not do what the user probably wants if the timezone is not hour-aligned.\r\n\r\ne.g. https://play.golang.org/p/hAfBrYWNeZ\r\n\r\nI suggest just removing the time.Hour example, and possibly explicitly suggest that Truncate cannot be used for times >= time.Hour because of timezones.\r\n\r\nI doubt we can actually change the implementation of Truncate at this point, so I've marked this a Documentation bug."},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/245436931","html_url":"https://github.com/golang/go/issues/16647#issuecomment-245436931","issue_url":"https://api.github.com/repos/golang/go/issues/16647","id":245436931,"user":{"login":"quentinmit","id":115761,"avatar_url":"https://avatars.githubusercontent.com/u/115761?v=3","gravatar_id":"","url":"https://api.github.com/users/quentinmit","html_url":"https://github.com/quentinmit","followers_url":"https://api.github.com/users/quentinmit/followers","following_url":"https://api.github.com/users/quentinmit/following{/other_user}","gists_url":"https://api.github.com/users/quentinmit/gists{/gist_id}","starred_url":"https://api.github.com/users/quentinmit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quentinmit/subscriptions","organizations_url":"https://api.github.com/users/quentinmit/orgs","repos_url":"https://api.github.com/users/quentinmit/repos","events_url":"https://api.github.com/users/quentinmit/events{/privacy}","received_events_url":"https://api.github.com/users/quentinmit/received_events","type":"User","site_admin":false},"created_at":"2016-09-07T22:16:36Z","updated_at":"2016-09-07T22:16:36Z","body":"I sent CL 28730 to clarify the docs.\r\n\r\nI think the behavior I want out of Truncate and Round is to be able to zero out the least significant fields of a time. That is, zero out the fractional seconds, or zero out the seconds, or zero out the minutes, or the hour, etc. In this particular case it came up because I want to bucket times in a way that I can then use a format string that omits the more detailed fields. For example, if I call 12:45 AM -> Truncate(Hour), I get back 12:30 AM (in some time zones). If I then go on to format that as 12 AM, that's very misleading, because it's actually the 12:30 AM - 1:30 AM bucket, not the 12 AM - 1 AM bucket.\r\n\r\nAs I pointed out with my playground link, it's not as simple as calling time.Date with some of the fields set to zero."}}
{"actor":{"display_login":"quentinmit"}}