{"action":"created","issue":{"url":"https://api.github.com/repos/collectd/go-collectd/issues/5","labels_url":"https://api.github.com/repos/collectd/go-collectd/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/collectd/go-collectd/issues/5/comments","events_url":"https://api.github.com/repos/collectd/go-collectd/issues/5/events","html_url":"https://github.com/collectd/go-collectd/pull/5","id":99772587,"number":5,"title":"nanosecond fix and additional test cases","user":{"login":"ryancox","id":111244,"avatar_url":"https://avatars.githubusercontent.com/u/111244?v=3","gravatar_id":"","url":"https://api.github.com/users/ryancox","html_url":"https://github.com/ryancox","followers_url":"https://api.github.com/users/ryancox/followers","following_url":"https://api.github.com/users/ryancox/following{/other_user}","gists_url":"https://api.github.com/users/ryancox/gists{/gist_id}","starred_url":"https://api.github.com/users/ryancox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryancox/subscriptions","organizations_url":"https://api.github.com/users/ryancox/orgs","repos_url":"https://api.github.com/users/ryancox/repos","events_url":"https://api.github.com/users/ryancox/events{/privacy}","received_events_url":"https://api.github.com/users/ryancox/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-08T04:57:33Z","updated_at":"2015-08-09T20:01:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/collectd/go-collectd/pulls/5","html_url":"https://github.com/collectd/go-collectd/pull/5","diff_url":"https://github.com/collectd/go-collectd/pull/5.diff","patch_url":"https://github.com/collectd/go-collectd/pull/5.patch"},"body":"I have been doing some work fuzz testing the network parsing code. While doing so, I noticed that I could not round-trip some packets that I captured via wireshark that contained high resolution cdtimes. The byte streams would be off by 1. I tracked this down to the newNano function and division by 1000000000. This forced a round. Since go rounds down, a nanosecond would be lost for non-zero nano-second values. I've added a fix for that as well as some additional test cases."},"comment":{"url":"https://api.github.com/repos/collectd/go-collectd/issues/comments/129232940","html_url":"https://github.com/collectd/go-collectd/pull/5#issuecomment-129232940","issue_url":"https://api.github.com/repos/collectd/go-collectd/issues/5","id":129232940,"user":{"login":"ryancox","id":111244,"avatar_url":"https://avatars.githubusercontent.com/u/111244?v=3","gravatar_id":"","url":"https://api.github.com/users/ryancox","html_url":"https://github.com/ryancox","followers_url":"https://api.github.com/users/ryancox/followers","following_url":"https://api.github.com/users/ryancox/following{/other_user}","gists_url":"https://api.github.com/users/ryancox/gists{/gist_id}","starred_url":"https://api.github.com/users/ryancox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryancox/subscriptions","organizations_url":"https://api.github.com/users/ryancox/orgs","repos_url":"https://api.github.com/users/ryancox/repos","events_url":"https://api.github.com/users/ryancox/events{/privacy}","received_events_url":"https://api.github.com/users/ryancox/received_events","type":"User","site_admin":false},"created_at":"2015-08-09T20:01:42Z","updated_at":"2015-08-09T20:01:42Z","body":"@octo I'm certainly open to better solutions. Adding a nano-second for non-zero values seemed to work empirically based on packets i had captured via wireshark as well as dates I created in tests cases.\r\n\r\nGave this a whirl but it's failing my test cases:\r\n```\r\n        s = s << 30\r\n\r\n        ns = ns % 1000000000\r\n-       ns = (ns << 30) / 1000000000\r\n-\r\n-       // division by a large number will necessitate a round; go rounds down\r\n-       // and will lose a nanosecond\r\n-       if ns != 0 {\r\n-               ns += 1\r\n-       }\r\n+       ns = ((ns << 30) + 500000000) / 1000000000\r\n\r\n        return Time(s | ns)\r\n }\r\n```\r\n\r\n```\t\r\ncdtime_test.go:56: got 2009-02-04T21:00:57.099999999-08:00, want 2009-02-04T21:00:57.1-08:00\r\ncdtime_test.go:56: got 2009-02-04T21:00:57.009999999-08:00, want 2009-02-04T21:00:57.01-08:00\r\ncdtime_test.go:56: got 2009-02-04T21:00:57.000099999-08:00, want 2009-02-04T21:00:57.0001-08:00\r\ncdtime_test.go:56: got 2009-02-04T21:00:57.000009999-08:00, want 2009-02-04T21:00:57.00001-08:00\r\ncdtime_test.go:56: got 2009-02-04T21:00:57.000000099-08:00, want 2009-02-04T21:00:57.0000001-08:00\r\n```\r\n"}}