{"action":"created","issue":{"url":"https://api.github.com/repos/jinzhu/now/issues/11","labels_url":"https://api.github.com/repos/jinzhu/now/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/jinzhu/now/issues/11/comments","events_url":"https://api.github.com/repos/jinzhu/now/issues/11/events","html_url":"https://github.com/jinzhu/now/issues/11","id":100984424,"number":11,"title":"Beginning/End of Next Month/Year/...","user":{"login":"phoet","id":48745,"avatar_url":"https://avatars.githubusercontent.com/u/48745?v=3","gravatar_id":"","url":"https://api.github.com/users/phoet","html_url":"https://github.com/phoet","followers_url":"https://api.github.com/users/phoet/followers","following_url":"https://api.github.com/users/phoet/following{/other_user}","gists_url":"https://api.github.com/users/phoet/gists{/gist_id}","starred_url":"https://api.github.com/users/phoet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phoet/subscriptions","organizations_url":"https://api.github.com/users/phoet/orgs","repos_url":"https://api.github.com/users/phoet/repos","events_url":"https://api.github.com/users/phoet/events{/privacy}","received_events_url":"https://api.github.com/users/phoet/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-14T10:36:55Z","updated_at":"2015-09-01T13:59:01Z","closed_at":"2015-09-01T08:21:05Z","body":"i'm a golang beginner used to rails awesome date-helpers that allow you do stuff like `1.month.ago` or `3.month.from_now`.\r\n\r\nin the same sense, i would like to calculate the timestamp of next month. i could not really find a great way to implement this in golang. maybe i just don't know the right tools though. \r\ncalculating it by hand is simple but has a lot of edge cases, so i would like to use it from within a library.\r\n\r\nany feedback appreciated."},"comment":{"url":"https://api.github.com/repos/jinzhu/now/issues/comments/136731454","html_url":"https://github.com/jinzhu/now/issues/11#issuecomment-136731454","issue_url":"https://api.github.com/repos/jinzhu/now/issues/11","id":136731454,"user":{"login":"phoet","id":48745,"avatar_url":"https://avatars.githubusercontent.com/u/48745?v=3","gravatar_id":"","url":"https://api.github.com/users/phoet","html_url":"https://github.com/phoet","followers_url":"https://api.github.com/users/phoet/followers","following_url":"https://api.github.com/users/phoet/following{/other_user}","gists_url":"https://api.github.com/users/phoet/gists{/gist_id}","starred_url":"https://api.github.com/users/phoet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phoet/subscriptions","organizations_url":"https://api.github.com/users/phoet/orgs","repos_url":"https://api.github.com/users/phoet/repos","events_url":"https://api.github.com/users/phoet/events{/privacy}","received_events_url":"https://api.github.com/users/phoet/received_events","type":"User","site_admin":false},"created_at":"2015-09-01T13:59:01Z","updated_at":"2015-09-01T13:59:01Z","body":"this is how i ended up implementing it:\r\n\r\n```golang\r\nfunc EndOfNextMonth() time.Time {\r\n\treturn calculateEndOfFollowingMonth(time.Now())\r\n}\r\n\r\nfunc calculateEndOfFollowingMonth(t time.Time) time.Time {\r\n\tyear := t.Year()\r\n\tmonth := t.Month()\r\n\tif month == time.December {\r\n\t\tyear += 1\r\n\t\tmonth = time.January\r\n\t} else {\r\n\t\tmonth = time.Month(int(month) + 1)\r\n\t}\r\n\ttm := time.Date(year, month, 1, 0, 0, 0, 0, time.Now().Location())\r\n\treturn now.New(tm).EndOfMonth()\r\n}\r\n```\r\n"}}