{"action":"created","comment":{"url":"https://api.github.com/repos/servo/servo/pulls/comments/154173307","pull_request_review_id":80293645,"id":154173307,"diff_hunk":"@@ -208,6 +208,114 @@ impl DOMString {\n         self.0.truncate(last_non_whitespace);\n         let _ = self.0.splice(0..first_non_whitespace, \"\");\n     }\n+\n+    /// A valid date string should be YYYY-MM-DD\n+    /// YYYY must be four or more digits, MM and DD both must be two digits\n+    /// https://html.spec.whatwg.org/multipage/#valid-date-string\n+    pub fn is_valid_date_string(&mut self) -> bool {\n+        match self.parse_date_component(&*self.0) {\n+            Ok(_)  => true,\n+            Err(_) => false\n+        }\n+    }\n+\n+    /// A valid month string should be \"YYYY-MM\"\n+    /// YYYY must be four or more digits, MM both must be two digits\n+    /// https://html.spec.whatwg.org/multipage/#valid-month-string\n+    pub fn is_valid_month_string(&mut self) -> bool {\n+        match self.parse_month_component(&*self.0) {\n+            Ok(_)  => true,\n+            Err(_) => false\n+        }\n+    }\n+\n+    /// https://html.spec.whatwg.org/multipage/#parse-a-month-component\n+    fn parse_month_component(&self, value: &str) -> Result<(u32, u32), ()> {\n+        // Step 3\n+        let value_vec: Vec<&str> = value.split('-').collect();\n+        if value_vec.len() < 2 || value_vec.len() > 3 {\n+            return Err(());\n+        }\n+        let year = value_vec[0];\n+        let month = value_vec[1];\n+\n+        // Step 1, 2\n+        if year.len() < 4 ||\n+           !year.chars().all(|c| c.is_digit(10)) ||\n+           year == \"0000\" {\n+            return Err(());\n+        }\n+\n+        // Step 4, 5\n+        let month_int = month.parse::<u32>().unwrap();\n+        if !(month.len() == 2 && month.chars().all(|c| c.is_digit(10))) {\n+            return Err(());\n+        } else if month_int > 12 || month_int < 1 {\n+            return Err(());\n+        }\n+\n+        // Step 6\n+        let year_int = year.parse::<u32>().unwrap();","path":"components/script/dom/bindings/str.rs","position":51,"original_position":51,"commit_id":"882e469d787be6190273ffdb14ef07aa6003f5ab","original_commit_id":"882e469d787be6190273ffdb14ef07aa6003f5ab","user":{"login":"KiChjang","id":3248587,"avatar_url":"https://avatars0.githubusercontent.com/u/3248587?v=4","gravatar_id":"","url":"https://api.github.com/users/KiChjang","html_url":"https://github.com/KiChjang","followers_url":"https://api.github.com/users/KiChjang/followers","following_url":"https://api.github.com/users/KiChjang/following{/other_user}","gists_url":"https://api.github.com/users/KiChjang/gists{/gist_id}","starred_url":"https://api.github.com/users/KiChjang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KiChjang/subscriptions","organizations_url":"https://api.github.com/users/KiChjang/orgs","repos_url":"https://api.github.com/users/KiChjang/repos","events_url":"https://api.github.com/users/KiChjang/events{/privacy}","received_events_url":"https://api.github.com/users/KiChjang/received_events","type":"User","site_admin":false},"body":"`year.parse::<u32>().map_err(|_| ())`","created_at":"2017-11-30T19:15:29Z","updated_at":"2017-11-30T19:35:17Z","html_url":"https://github.com/servo/servo/pull/19385#discussion_r154173307","pull_request_url":"https://api.github.com/repos/servo/servo/pulls/19385","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/servo/servo/pulls/comments/154173307"},"html":{"href":"https://github.com/servo/servo/pull/19385#discussion_r154173307"},"pull_request":{"href":"https://api.github.com/repos/servo/servo/pulls/19385"}}},"pull_request":{"url":"https://api.github.com/repos/servo/servo/pulls/19385","id":154693288,"html_url":"https://github.com/servo/servo/pull/19385","diff_url":"https://github.com/servo/servo/pull/19385.diff","patch_url":"https://github.com/servo/servo/pull/19385.patch","issue_url":"https://api.github.com/repos/servo/servo/issues/19385","number":19385,"state":"open","locked":false,"title":"implement  \"Date type inputs\", \"Month type inputs\", \"valid date string\" and \"valid month string\"","user":{"login":"tigercosmos","id":18013815,"avatar_url":"https://avatars0.githubusercontent.com/u/18013815?v=4","gravatar_id":"","url":"https://api.github.com/users/tigercosmos","html_url":"https://github.com/tigercosmos","followers_url":"https://api.github.com/users/tigercosmos/followers","following_url":"https://api.github.com/users/tigercosmos/following{/other_user}","gists_url":"https://api.github.com/users/tigercosmos/gists{/gist_id}","starred_url":"https://api.github.com/users/tigercosmos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tigercosmos/subscriptions","organizations_url":"https://api.github.com/users/tigercosmos/orgs","repos_url":"https://api.github.com/users/tigercosmos/repos","events_url":"https://api.github.com/users/tigercosmos/events{/privacy}","received_events_url":"https://api.github.com/users/tigercosmos/received_events","type":"User","site_admin":false},"body":"<!-- Please describe your changes on the following line: -->\r\nin #19172\r\n-  Date type inputs\r\n-  Month type inputs\r\n- Week type inputs\r\n\r\nwill need `valid date string` and `valid month string`.\r\n\r\nOther can work on sub-itmes in #19172 when this PR lands.\r\n\r\n\r\n---\r\n<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->\r\n- [X] `./mach build -d` does not report any errors\r\n- [X] `./mach test-tidy` does not report any errors\r\n- [X] `./mach test-unit` does not report any errors\r\n\r\n<!-- Reviewable:start -->\r\n---\r\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/servo/servo/19385)\r\n<!-- Reviewable:end -->\r\n","created_at":"2017-11-26T19:34:47Z","updated_at":"2017-11-30T19:35:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9dbb3a6adbe344fb132efa5051c821648d966620","assignee":{"login":"KiChjang","id":3248587,"avatar_url":"https://avatars0.githubusercontent.com/u/3248587?v=4","gravatar_id":"","url":"https://api.github.com/users/KiChjang","html_url":"https://github.com/KiChjang","followers_url":"https://api.github.com/users/KiChjang/followers","following_url":"https://api.github.com/users/KiChjang/following{/other_user}","gists_url":"https://api.github.com/users/KiChjang/gists{/gist_id}","starred_url":"https://api.github.com/users/KiChjang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KiChjang/subscriptions","organizations_url":"https://api.github.com/users/KiChjang/orgs","repos_url":"https://api.github.com/users/KiChjang/repos","events_url":"https://api.github.com/users/KiChjang/events{/privacy}","received_events_url":"https://api.github.com/users/KiChjang/received_events","type":"User","site_admin":false},"assignees":[{"login":"KiChjang","id":3248587,"avatar_url":"https://avatars0.githubusercontent.com/u/3248587?v=4","gravatar_id":"","url":"https://api.github.com/users/KiChjang","html_url":"https://github.com/KiChjang","followers_url":"https://api.github.com/users/KiChjang/followers","following_url":"https://api.github.com/users/KiChjang/following{/other_user}","gists_url":"https://api.github.com/users/KiChjang/gists{/gist_id}","starred_url":"https://api.github.com/users/KiChjang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KiChjang/subscriptions","organizations_url":"https://api.github.com/users/KiChjang/orgs","repos_url":"https://api.github.com/users/KiChjang/repos","events_url":"https://api.github.com/users/KiChjang/events{/privacy}","received_events_url":"https://api.github.com/users/KiChjang/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/servo/servo/pulls/19385/commits","review_comments_url":"https://api.github.com/repos/servo/servo/pulls/19385/comments","review_comment_url":"https://api.github.com/repos/servo/servo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/servo/servo/issues/19385/comments","statuses_url":"https://api.github.com/repos/servo/servo/statuses/882e469d787be6190273ffdb14ef07aa6003f5ab","head":{"label":"tigercosmos:b1","ref":"b1","sha":"882e469d787be6190273ffdb14ef07aa6003f5ab","user":{"login":"tigercosmos","id":18013815,"avatar_url":"https://avatars0.githubusercontent.com/u/18013815?v=4","gravatar_id":"","url":"https://api.github.com/users/tigercosmos","html_url":"https://github.com/tigercosmos","followers_url":"https://api.github.com/users/tigercosmos/followers","following_url":"https://api.github.com/users/tigercosmos/following{/other_user}","gists_url":"https://api.github.com/users/tigercosmos/gists{/gist_id}","starred_url":"https://api.github.com/users/tigercosmos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tigercosmos/subscriptions","organizations_url":"https://api.github.com/users/tigercosmos/orgs","repos_url":"https://api.github.com/users/tigercosmos/repos","events_url":"https://api.github.com/users/tigercosmos/events{/privacy}","received_events_url":"https://api.github.com/users/tigercosmos/received_events","type":"User","site_admin":false},"repo":{"id":100714943,"name":"servo","full_name":"tigercosmos/servo","owner":{"login":"tigercosmos","id":18013815,"avatar_url":"https://avatars0.githubusercontent.com/u/18013815?v=4","gravatar_id":"","url":"https://api.github.com/users/tigercosmos","html_url":"https://github.com/tigercosmos","followers_url":"https://api.github.com/users/tigercosmos/followers","following_url":"https://api.github.com/users/tigercosmos/following{/other_user}","gists_url":"https://api.github.com/users/tigercosmos/gists{/gist_id}","starred_url":"https://api.github.com/users/tigercosmos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tigercosmos/subscriptions","organizations_url":"https://api.github.com/users/tigercosmos/orgs","repos_url":"https://api.github.com/users/tigercosmos/repos","events_url":"https://api.github.com/users/tigercosmos/events{/privacy}","received_events_url":"https://api.github.com/users/tigercosmos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tigercosmos/servo","description":"The Servo Browser Engine","fork":true,"url":"https://api.github.com/repos/tigercosmos/servo","forks_url":"https://api.github.com/repos/tigercosmos/servo/forks","keys_url":"https://api.github.com/repos/tigercosmos/servo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tigercosmos/servo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tigercosmos/servo/teams","hooks_url":"https://api.github.com/repos/tigercosmos/servo/hooks","issue_events_url":"https://api.github.com/repos/tigercosmos/servo/issues/events{/number}","events_url":"https://api.github.com/repos/tigercosmos/servo/events","assignees_url":"https://api.github.com/repos/tigercosmos/servo/assignees{/user}","branches_url":"https://api.github.com/repos/tigercosmos/servo/branches{/branch}","tags_url":"https://api.github.com/repos/tigercosmos/servo/tags","blobs_url":"https://api.github.com/repos/tigercosmos/servo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tigercosmos/servo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tigercosmos/servo/git/refs{/sha}","trees_url":"https://api.github.com/repos/tigercosmos/servo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tigercosmos/servo/statuses/{sha}","languages_url":"https://api.github.com/repos/tigercosmos/servo/languages","stargazers_url":"https://api.github.com/repos/tigercosmos/servo/stargazers","contributors_url":"https://api.github.com/repos/tigercosmos/servo/contributors","subscribers_url":"https://api.github.com/repos/tigercosmos/servo/subscribers","subscription_url":"https://api.github.com/repos/tigercosmos/servo/subscription","commits_url":"https://api.github.com/repos/tigercosmos/servo/commits{/sha}","git_commits_url":"https://api.github.com/repos/tigercosmos/servo/git/commits{/sha}","comments_url":"https://api.github.com/repos/tigercosmos/servo/comments{/number}","issue_comment_url":"https://api.github.com/repos/tigercosmos/servo/issues/comments{/number}","contents_url":"https://api.github.com/repos/tigercosmos/servo/contents/{+path}","compare_url":"https://api.github.com/repos/tigercosmos/servo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tigercosmos/servo/merges","archive_url":"https://api.github.com/repos/tigercosmos/servo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tigercosmos/servo/downloads","issues_url":"https://api.github.com/repos/tigercosmos/servo/issues{/number}","pulls_url":"https://api.github.com/repos/tigercosmos/servo/pulls{/number}","milestones_url":"https://api.github.com/repos/tigercosmos/servo/milestones{/number}","notifications_url":"https://api.github.com/repos/tigercosmos/servo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tigercosmos/servo/labels{/name}","releases_url":"https://api.github.com/repos/tigercosmos/servo/releases{/id}","deployments_url":"https://api.github.com/repos/tigercosmos/servo/deployments","created_at":"2017-08-18T13:31:45Z","updated_at":"2017-11-05T13:18:26Z","pushed_at":"2017-11-30T15:45:09Z","git_url":"git://github.com/tigercosmos/servo.git","ssh_url":"git@github.com:tigercosmos/servo.git","clone_url":"https://github.com/tigercosmos/servo.git","svn_url":"https://github.com/tigercosmos/servo","homepage":"https://servo.org/","size":317287,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"servo:master","ref":"master","sha":"fce44a2e139478a5fc3524c2fd72fbeea6e3eec1","user":{"login":"servo","id":2566135,"avatar_url":"https://avatars1.githubusercontent.com/u/2566135?v=4","gravatar_id":"","url":"https://api.github.com/users/servo","html_url":"https://github.com/servo","followers_url":"https://api.github.com/users/servo/followers","following_url":"https://api.github.com/users/servo/following{/other_user}","gists_url":"https://api.github.com/users/servo/gists{/gist_id}","starred_url":"https://api.github.com/users/servo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/servo/subscriptions","organizations_url":"https://api.github.com/users/servo/orgs","repos_url":"https://api.github.com/users/servo/repos","events_url":"https://api.github.com/users/servo/events{/privacy}","received_events_url":"https://api.github.com/users/servo/received_events","type":"Organization","site_admin":false},"repo":{"id":3390243,"name":"servo","full_name":"servo/servo","owner":{"login":"servo","id":2566135,"avatar_url":"https://avatars1.githubusercontent.com/u/2566135?v=4","gravatar_id":"","url":"https://api.github.com/users/servo","html_url":"https://github.com/servo","followers_url":"https://api.github.com/users/servo/followers","following_url":"https://api.github.com/users/servo/following{/other_user}","gists_url":"https://api.github.com/users/servo/gists{/gist_id}","starred_url":"https://api.github.com/users/servo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/servo/subscriptions","organizations_url":"https://api.github.com/users/servo/orgs","repos_url":"https://api.github.com/users/servo/repos","events_url":"https://api.github.com/users/servo/events{/privacy}","received_events_url":"https://api.github.com/users/servo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/servo/servo","description":"The Servo Browser Engine","fork":false,"url":"https://api.github.com/repos/servo/servo","forks_url":"https://api.github.com/repos/servo/servo/forks","keys_url":"https://api.github.com/repos/servo/servo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/servo/servo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/servo/servo/teams","hooks_url":"https://api.github.com/repos/servo/servo/hooks","issue_events_url":"https://api.github.com/repos/servo/servo/issues/events{/number}","events_url":"https://api.github.com/repos/servo/servo/events","assignees_url":"https://api.github.com/repos/servo/servo/assignees{/user}","branches_url":"https://api.github.com/repos/servo/servo/branches{/branch}","tags_url":"https://api.github.com/repos/servo/servo/tags","blobs_url":"https://api.github.com/repos/servo/servo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/servo/servo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/servo/servo/git/refs{/sha}","trees_url":"https://api.github.com/repos/servo/servo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/servo/servo/statuses/{sha}","languages_url":"https://api.github.com/repos/servo/servo/languages","stargazers_url":"https://api.github.com/repos/servo/servo/stargazers","contributors_url":"https://api.github.com/repos/servo/servo/contributors","subscribers_url":"https://api.github.com/repos/servo/servo/subscribers","subscription_url":"https://api.github.com/repos/servo/servo/subscription","commits_url":"https://api.github.com/repos/servo/servo/commits{/sha}","git_commits_url":"https://api.github.com/repos/servo/servo/git/commits{/sha}","comments_url":"https://api.github.com/repos/servo/servo/comments{/number}","issue_comment_url":"https://api.github.com/repos/servo/servo/issues/comments{/number}","contents_url":"https://api.github.com/repos/servo/servo/contents/{+path}","compare_url":"https://api.github.com/repos/servo/servo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/servo/servo/merges","archive_url":"https://api.github.com/repos/servo/servo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/servo/servo/downloads","issues_url":"https://api.github.com/repos/servo/servo/issues{/number}","pulls_url":"https://api.github.com/repos/servo/servo/pulls{/number}","milestones_url":"https://api.github.com/repos/servo/servo/milestones{/number}","notifications_url":"https://api.github.com/repos/servo/servo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/servo/servo/labels{/name}","releases_url":"https://api.github.com/repos/servo/servo/releases{/id}","deployments_url":"https://api.github.com/repos/servo/servo/deployments","created_at":"2012-02-08T19:07:25Z","updated_at":"2017-11-30T14:20:11Z","pushed_at":"2017-11-30T19:24:52Z","git_url":"git://github.com/servo/servo.git","ssh_url":"git@github.com:servo/servo.git","clone_url":"https://github.com/servo/servo.git","svn_url":"https://github.com/servo/servo","homepage":"https://servo.org/","size":395719,"stargazers_count":10720,"watchers_count":10720,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1793,"mirror_url":null,"archived":false,"open_issues_count":1992,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":1793,"open_issues":1992,"watchers":10720,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/servo/servo/pulls/19385"},"html":{"href":"https://github.com/servo/servo/pull/19385"},"issue":{"href":"https://api.github.com/repos/servo/servo/issues/19385"},"comments":{"href":"https://api.github.com/repos/servo/servo/issues/19385/comments"},"review_comments":{"href":"https://api.github.com/repos/servo/servo/pulls/19385/comments"},"review_comment":{"href":"https://api.github.com/repos/servo/servo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/servo/servo/pulls/19385/commits"},"statuses":{"href":"https://api.github.com/repos/servo/servo/statuses/882e469d787be6190273ffdb14ef07aa6003f5ab"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"KiChjang"}}