{"action":"created","issue":{"url":"https://api.github.com/repos/moment/moment/issues/529","repository_url":"https://api.github.com/repos/moment/moment","labels_url":"https://api.github.com/repos/moment/moment/issues/529/labels{/name}","comments_url":"https://api.github.com/repos/moment/moment/issues/529/comments","events_url":"https://api.github.com/repos/moment/moment/issues/529/events","html_url":"https://github.com/moment/moment/issues/529","id":8725514,"number":529,"title":"Get week ranges for a given month?","user":{"login":"simov","id":1694112,"avatar_url":"https://avatars.githubusercontent.com/u/1694112?v=3","gravatar_id":"","url":"https://api.github.com/users/simov","html_url":"https://github.com/simov","followers_url":"https://api.github.com/users/simov/followers","following_url":"https://api.github.com/users/simov/following{/other_user}","gists_url":"https://api.github.com/users/simov/gists{/gist_id}","starred_url":"https://api.github.com/users/simov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simov/subscriptions","organizations_url":"https://api.github.com/users/simov/orgs","repos_url":"https://api.github.com/users/simov/repos","events_url":"https://api.github.com/users/simov/events{/privacy}","received_events_url":"https://api.github.com/users/simov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2012-11-27T15:59:57Z","updated_at":"2016-10-22T09:16:11Z","closed_at":"2012-11-27T20:14:31Z","body":"I needed a way to get the week ranges (start/end day) for a given month. I ended up with this hacky solution:\n```js\nfunction weeks (month) {\n    month = moment(month, 'YYYY-MM-DD');\n\n    var first = month.day() == 0 ? 6 : month.day()-1;\n    var day = 7-first;\n\n    var last = month.daysInMonth();\n    var count = (last-day)/7;\n\n    var weeks = [];\n    weeks.push([1, day]);\n    for (var i=0; i < count; i++) {\n        weeks.push([(day+1), (Math.min(day+=7, last))]);\n        \n    }\n    return weeks;\n}\n```\nhttp://jsfiddle.net/simo/xPcEm/\nIs there a better (cleaner) way to accomplish this?\nThanks!"},"comment":{"url":"https://api.github.com/repos/moment/moment/issues/comments/255517058","html_url":"https://github.com/moment/moment/issues/529#issuecomment-255517058","issue_url":"https://api.github.com/repos/moment/moment/issues/529","id":255517058,"user":{"login":"jhabdas","id":440298,"avatar_url":"https://avatars.githubusercontent.com/u/440298?v=3","gravatar_id":"","url":"https://api.github.com/users/jhabdas","html_url":"https://github.com/jhabdas","followers_url":"https://api.github.com/users/jhabdas/followers","following_url":"https://api.github.com/users/jhabdas/following{/other_user}","gists_url":"https://api.github.com/users/jhabdas/gists{/gist_id}","starred_url":"https://api.github.com/users/jhabdas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhabdas/subscriptions","organizations_url":"https://api.github.com/users/jhabdas/orgs","repos_url":"https://api.github.com/users/jhabdas/repos","events_url":"https://api.github.com/users/jhabdas/events{/privacy}","received_events_url":"https://api.github.com/users/jhabdas/received_events","type":"User","site_admin":false},"created_at":"2016-10-22T09:16:11Z","updated_at":"2016-10-22T09:16:11Z","body":"@timrwood thoughts on the above line of questioning before I open a bug? Looking at October on the Calendar it starts on a Sunday and ends on a Monday, covering a 6 week period (and not 5).\r\n\r\nMy use case personally was to create a bar graph with one bar for each week in the month. This seems it should be a trivial endeavor. But I had difficulty in doing so, and it seems others are as well."}}
{"actor":{"display_login":"jhabdas"}}