{"action":"created","issue":{"url":"https://api.github.com/repos/angular/material/issues/4776","labels_url":"https://api.github.com/repos/angular/material/issues/4776/labels{/name}","comments_url":"https://api.github.com/repos/angular/material/issues/4776/comments","events_url":"https://api.github.com/repos/angular/material/issues/4776/events","html_url":"https://github.com/angular/material/issues/4776","id":107763661,"number":4776,"title":"md-datepicker: problems changing value for en-gb locale (probably others too)","user":{"login":"bluebirdtech","id":3141867,"avatar_url":"https://avatars.githubusercontent.com/u/3141867?v=3","gravatar_id":"","url":"https://api.github.com/users/bluebirdtech","html_url":"https://github.com/bluebirdtech","followers_url":"https://api.github.com/users/bluebirdtech/followers","following_url":"https://api.github.com/users/bluebirdtech/following{/other_user}","gists_url":"https://api.github.com/users/bluebirdtech/gists{/gist_id}","starred_url":"https://api.github.com/users/bluebirdtech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluebirdtech/subscriptions","organizations_url":"https://api.github.com/users/bluebirdtech/orgs","repos_url":"https://api.github.com/users/bluebirdtech/repos","events_url":"https://api.github.com/users/bluebirdtech/events{/privacy}","received_events_url":"https://api.github.com/users/bluebirdtech/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/material/labels/type:%20bug","name":"type: bug","color":"000000"}],"state":"closed","locked":false,"assignee":{"login":"jelbourn","id":838736,"avatar_url":"https://avatars.githubusercontent.com/u/838736?v=3","gravatar_id":"","url":"https://api.github.com/users/jelbourn","html_url":"https://github.com/jelbourn","followers_url":"https://api.github.com/users/jelbourn/followers","following_url":"https://api.github.com/users/jelbourn/following{/other_user}","gists_url":"https://api.github.com/users/jelbourn/gists{/gist_id}","starred_url":"https://api.github.com/users/jelbourn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelbourn/subscriptions","organizations_url":"https://api.github.com/users/jelbourn/orgs","repos_url":"https://api.github.com/users/jelbourn/repos","events_url":"https://api.github.com/users/jelbourn/events{/privacy}","received_events_url":"https://api.github.com/users/jelbourn/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/angular/material/milestones/17","html_url":"https://github.com/angular/material/milestones/0.12.0","labels_url":"https://api.github.com/repos/angular/material/milestones/17/labels","id":1166984,"number":17,"title":"0.12.0","description":"Polish and Bugfixes leading up to 1.0\r\n","creator":{"login":"robertmesserle","id":571363,"avatar_url":"https://avatars.githubusercontent.com/u/571363?v=3","gravatar_id":"","url":"https://api.github.com/users/robertmesserle","html_url":"https://github.com/robertmesserle","followers_url":"https://api.github.com/users/robertmesserle/followers","following_url":"https://api.github.com/users/robertmesserle/following{/other_user}","gists_url":"https://api.github.com/users/robertmesserle/gists{/gist_id}","starred_url":"https://api.github.com/users/robertmesserle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertmesserle/subscriptions","organizations_url":"https://api.github.com/users/robertmesserle/orgs","repos_url":"https://api.github.com/users/robertmesserle/repos","events_url":"https://api.github.com/users/robertmesserle/events{/privacy}","received_events_url":"https://api.github.com/users/robertmesserle/received_events","type":"User","site_admin":false},"open_issues":552,"closed_issues":365,"state":"open","created_at":"2015-06-16T15:48:24Z","updated_at":"2015-09-22T21:23:18Z","due_on":"2015-09-29T05:00:00Z","closed_at":null},"comments":4,"created_at":"2015-09-22T17:41:28Z","updated_at":"2015-09-22T21:26:28Z","closed_at":"2015-09-22T18:39:28Z","body":"Repro: In the demo for md-datepicker at head, while using Chrome on Windows with en-gb locale, select the month date component and replace it with another valid month value.\r\n\r\nResult: Month and day components sometimes swap around.  And other times the input becomes invalid.\r\n\r\nExpected: Month value is replaced and the value change is propagated the model.\r\n\r\nWorkaround: Use moment.js to parse the date, using the current browser culture:\r\n````\r\n    myAppModule.config(function($mdDateLocaleProvider) {\r\n        var locale = window.navigator.userLanguage || window.navigator.language;\r\n        moment.locale(locale);\r\n\r\n        $mdDateLocaleProvider.parseDate = function(dateString) {\r\n            var m = moment(dateString, 'L', true);\r\n            return m.isValid() ? m.toDate() : new Date(NaN);\r\n        };\r\n        $mdDateLocaleProvider.formatDate = function(date) {\r\n            return moment(date).format('L');\r\n        };\r\n    });\r\n````\r\n\r\nThoughts:\r\nGiven Date.parse is unreliable, will there need to be a strong recommendation to use a custom provider based on eg. moment.js to handle international date formats nicely?\r\n\r\nSub-issues:\r\n - In the md-date-locale-provider example, parse date is expecting an ISO-8601 formatted string. I suspect this is rarely helpful, but instead the sample could be updated to include a section from the above workaround.\r\n - It would be nice if parseDate accepted a falsy return value as invalid. With null/undefined it crashes, where new Date(NaN) successfully sets the invalid state."},"comment":{"url":"https://api.github.com/repos/angular/material/issues/comments/142427803","html_url":"https://github.com/angular/material/issues/4776#issuecomment-142427803","issue_url":"https://api.github.com/repos/angular/material/issues/4776","id":142427803,"user":{"login":"bluebirdtech","id":3141867,"avatar_url":"https://avatars.githubusercontent.com/u/3141867?v=3","gravatar_id":"","url":"https://api.github.com/users/bluebirdtech","html_url":"https://github.com/bluebirdtech","followers_url":"https://api.github.com/users/bluebirdtech/followers","following_url":"https://api.github.com/users/bluebirdtech/following{/other_user}","gists_url":"https://api.github.com/users/bluebirdtech/gists{/gist_id}","starred_url":"https://api.github.com/users/bluebirdtech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluebirdtech/subscriptions","organizations_url":"https://api.github.com/users/bluebirdtech/orgs","repos_url":"https://api.github.com/users/bluebirdtech/repos","events_url":"https://api.github.com/users/bluebirdtech/events{/privacy}","received_events_url":"https://api.github.com/users/bluebirdtech/received_events","type":"User","site_admin":false},"created_at":"2015-09-22T21:26:28Z","updated_at":"2015-09-22T21:26:28Z","body":"Great :)  I should really get comfortable submitting PRs."}}