{"action":"opened","issue":{"url":"https://api.github.com/repos/google/closure-library/issues/427","labels_url":"https://api.github.com/repos/google/closure-library/issues/427/labels{/name}","comments_url":"https://api.github.com/repos/google/closure-library/issues/427/comments","events_url":"https://api.github.com/repos/google/closure-library/issues/427/events","html_url":"https://github.com/google/closure-library/issues/427","id":61348795,"number":427,"title":"Cut off weekday bug in goog.date.getWeekNumber when it is 0 (goog.date.weekDay.MON)","user":{"login":"blueoctopus","id":613107,"avatar_url":"https://avatars.githubusercontent.com/u/613107?v=3","gravatar_id":"","url":"https://api.github.com/users/blueoctopus","html_url":"https://github.com/blueoctopus","followers_url":"https://api.github.com/users/blueoctopus/followers","following_url":"https://api.github.com/users/blueoctopus/following{/other_user}","gists_url":"https://api.github.com/users/blueoctopus/gists{/gist_id}","starred_url":"https://api.github.com/users/blueoctopus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blueoctopus/subscriptions","organizations_url":"https://api.github.com/users/blueoctopus/orgs","repos_url":"https://api.github.com/users/blueoctopus/repos","events_url":"https://api.github.com/users/blueoctopus/events{/privacy}","received_events_url":"https://api.github.com/users/blueoctopus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-14T01:54:20Z","updated_at":"2015-03-14T01:54:20Z","closed_at":null,"body":"The following call is expected to return `52`, but instead it returns `1`:\r\n\r\n```javascript\r\ngoog.date.getWeekNumber(2015, 0, 1, goog.date.weekDay.MON, goog.date.weekDay.FRI);\r\n```\r\n\r\nThe bug is in this line:\r\n\r\n```javascript\r\n  // Default to Thursday for cut off as per ISO 8601.\r\n  var cutoff = opt_weekDay || goog.date.weekDay.THU;\r\n```\r\n\r\n`cutoff` should only default to Thursday when opt_weekDay is `undefined`, not when it's `0`.\r\n\r\nA workaround that I was able to find (without reimplementing the whole function again) is replacing `goog.date.weekDay.MON` with `7`:\r\n\r\n```javascript\r\nvar cutoffWeekDay = goog.date.weekDay.MON;\r\ngoog.date.getWeekNumber(2015, 0, 1, cutoffWeekDay || 7, goog.date.weekDay.FRI);\r\n```\r\n\r\nThis will return `52`, as expected.\r\n\r\nBecause of this, it will be nice if you can keep supporting `7` as a cutoff value to mean Monday for `opt_weekDay` after patching this function."}}