{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/44421543","id":44421543,"diff_hunk":"@@ -251,9 +269,53 @@ var edx = edx || {};\n \t    }\n \t},\n \n+\tvalid_dates: function(start, due) {\n+          var errorMessage;\n+          // Start date is compulsory and due date is optional.\n+          if (_.isEmpty(start) && !_.isEmpty(due)) {\n+            errorMessage = gettext(\"Please enter valid start date and time.\");\n+          } else if (!_.isEmpty(start) && !_.isEmpty(due)) {\n+            var dueParts = self.parse_date(due);\n+            var startParts = self.parse_date(start);\n+            var dueDate = new Date(\n+              dueParts[0],\n+              dueParts[1],\n+              dueParts[2],\n+              dueParts[3],\n+              dueParts[4]\n+            );\n+            var startDate = new Date(\n+              startParts[0],\n+              startParts[1],\n+              startParts[2],\n+              startParts[3],\n+              startParts[4]\n+\t\t\t\t\t\t);\n+            if (dueDate < startDate) {\n+              errorMessage = gettext(\"Due date cannot be before start date.\");\n+            }\n+          }\n+          return errorMessage;\n+\t},\n+\n+\tparse_date: function(date) {","path":"lms/static/js/ccx/schedule.js","position":92,"original_position":92,"commit_id":"ee5963e9840190e2322cc7ae797b337503b159c3","original_commit_id":"ee5963e9840190e2322cc7ae797b337503b159c3","user":{"login":"singingwolfboy","id":132355,"avatar_url":"https://avatars.githubusercontent.com/u/132355?v=3","gravatar_id":"","url":"https://api.github.com/users/singingwolfboy","html_url":"https://github.com/singingwolfboy","followers_url":"https://api.github.com/users/singingwolfboy/followers","following_url":"https://api.github.com/users/singingwolfboy/following{/other_user}","gists_url":"https://api.github.com/users/singingwolfboy/gists{/gist_id}","starred_url":"https://api.github.com/users/singingwolfboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/singingwolfboy/subscriptions","organizations_url":"https://api.github.com/users/singingwolfboy/orgs","repos_url":"https://api.github.com/users/singingwolfboy/repos","events_url":"https://api.github.com/users/singingwolfboy/events{/privacy}","received_events_url":"https://api.github.com/users/singingwolfboy/received_events","type":"User","site_admin":false},"body":"Gah, on my last review I was too focused on checking this line-by-line, and I didn't step back to see the larger picture. For parsing and manipulating dates and times, you should use the [moment.js](http://momentjs.com/) library, which is already being used in the platform. It looks like the format you're parsing is *almost* [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), but you're using a space separator instead of a `T` separator between the date and time. Fortunately, this is very common, so moment.js should still handle it automatically. You can parse the string simply by doing:\r\n```js\r\nreturn moment(date)  // returns a Moment object, not an Array\r\n```\r\nIf you want to transform that Moment object to a native Date object, or an array of integers like what you're doing now, you can call the [`asDate()`](http://momentjs.com/docs/#/displaying/as-javascript-date/) or [`asArray()`](http://momentjs.com/docs/#/displaying/as-array/) methods.","created_at":"2015-11-10T15:45:22Z","updated_at":"2015-11-10T15:45:22Z","html_url":"https://github.com/edx/edx-platform/pull/10538#discussion_r44421543","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/10538","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/44421543"},"html":{"href":"https://github.com/edx/edx-platform/pull/10538#discussion_r44421543"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10538"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/10538","id":49947762,"html_url":"https://github.com/edx/edx-platform/pull/10538","diff_url":"https://github.com/edx/edx-platform/pull/10538.diff","patch_url":"https://github.com/edx/edx-platform/pull/10538.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/10538","number":10538,"state":"open","locked":false,"title":"Added validations for start and due date in Schedule tab inside CCX coach dashboard","user":{"login":"amir-qayyum-khan","id":10431250,"avatar_url":"https://avatars.githubusercontent.com/u/10431250?v=3","gravatar_id":"","url":"https://api.github.com/users/amir-qayyum-khan","html_url":"https://github.com/amir-qayyum-khan","followers_url":"https://api.github.com/users/amir-qayyum-khan/followers","following_url":"https://api.github.com/users/amir-qayyum-khan/following{/other_user}","gists_url":"https://api.github.com/users/amir-qayyum-khan/gists{/gist_id}","starred_url":"https://api.github.com/users/amir-qayyum-khan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amir-qayyum-khan/subscriptions","organizations_url":"https://api.github.com/users/amir-qayyum-khan/orgs","repos_url":"https://api.github.com/users/amir-qayyum-khan/repos","events_url":"https://api.github.com/users/amir-qayyum-khan/events{/privacy}","received_events_url":"https://api.github.com/users/amir-qayyum-khan/received_events","type":"User","site_admin":false},"body":"### Background\r\nFrom issue https://github.com/mitocw/edx-platform/issues/79 and https://github.com/mitocw/edx-platform/issues/39\r\n\r\n### What is done in this PR\r\n**Studio Updates:** None.\r\n\r\n**LMS Updates:** \r\n- Showing error message incase user do not specify a time with date in ```add unit form``` inside ccx coach schedule tab.\r\n- Showing error message in case start date is greater the due date i.e added date validation in ```add unit form``` inside ccx coach schedule tab.\r\n\r\n@pdpinch @giocalitri  @pwilkins\r\nMIT PR https://github.com/mitocw/edx-platform/pull/97\r\n\r\n![screen shot 2015-10-07 at 3 09 16 pm](https://cloud.githubusercontent.com/assets/10431250/10334719/73721222-6d05-11e5-909e-e8e212e4d9d0.png)\r\n\r\n![screen shot 2015-10-07 at 4 36 45 pm](https://cloud.githubusercontent.com/assets/10431250/10336689/09af3aea-6d14-11e5-8fe1-9235c570a959.png)\r\n ","created_at":"2015-11-06T12:24:44Z","updated_at":"2015-11-10T15:45:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e59b57f2f4fe9df6e18cffd8f3c3ad94a5b75f16","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/10538/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/10538/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/10538/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/ee5963e9840190e2322cc7ae797b337503b159c3","head":{"label":"mitocw:fix/aq/error/validation_on_start_time","ref":"fix/aq/error/validation_on_start_time","sha":"ee5963e9840190e2322cc7ae797b337503b159c3","user":{"login":"mitocw","id":3009146,"avatar_url":"https://avatars.githubusercontent.com/u/3009146?v=3","gravatar_id":"","url":"https://api.github.com/users/mitocw","html_url":"https://github.com/mitocw","followers_url":"https://api.github.com/users/mitocw/followers","following_url":"https://api.github.com/users/mitocw/following{/other_user}","gists_url":"https://api.github.com/users/mitocw/gists{/gist_id}","starred_url":"https://api.github.com/users/mitocw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitocw/subscriptions","organizations_url":"https://api.github.com/users/mitocw/orgs","repos_url":"https://api.github.com/users/mitocw/repos","events_url":"https://api.github.com/users/mitocw/events{/privacy}","received_events_url":"https://api.github.com/users/mitocw/received_events","type":"Organization","site_admin":false},"repo":{"id":17842334,"name":"edx-platform","full_name":"mitocw/edx-platform","owner":{"login":"mitocw","id":3009146,"avatar_url":"https://avatars.githubusercontent.com/u/3009146?v=3","gravatar_id":"","url":"https://api.github.com/users/mitocw","html_url":"https://github.com/mitocw","followers_url":"https://api.github.com/users/mitocw/followers","following_url":"https://api.github.com/users/mitocw/following{/other_user}","gists_url":"https://api.github.com/users/mitocw/gists{/gist_id}","starred_url":"https://api.github.com/users/mitocw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitocw/subscriptions","organizations_url":"https://api.github.com/users/mitocw/orgs","repos_url":"https://api.github.com/users/mitocw/repos","events_url":"https://api.github.com/users/mitocw/events{/privacy}","received_events_url":"https://api.github.com/users/mitocw/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitocw/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/mitocw/edx-platform","forks_url":"https://api.github.com/repos/mitocw/edx-platform/forks","keys_url":"https://api.github.com/repos/mitocw/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitocw/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitocw/edx-platform/teams","hooks_url":"https://api.github.com/repos/mitocw/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/mitocw/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/mitocw/edx-platform/events","assignees_url":"https://api.github.com/repos/mitocw/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/mitocw/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/mitocw/edx-platform/tags","blobs_url":"https://api.github.com/repos/mitocw/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitocw/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitocw/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitocw/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitocw/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/mitocw/edx-platform/languages","stargazers_url":"https://api.github.com/repos/mitocw/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/mitocw/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/mitocw/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/mitocw/edx-platform/subscription","commits_url":"https://api.github.com/repos/mitocw/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitocw/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitocw/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitocw/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitocw/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/mitocw/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitocw/edx-platform/merges","archive_url":"https://api.github.com/repos/mitocw/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitocw/edx-platform/downloads","issues_url":"https://api.github.com/repos/mitocw/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/mitocw/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/mitocw/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/mitocw/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitocw/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/mitocw/edx-platform/releases{/id}","created_at":"2014-03-17T20:32:05Z","updated_at":"2015-10-30T14:00:48Z","pushed_at":"2015-11-10T15:02:14Z","git_url":"git://github.com/mitocw/edx-platform.git","ssh_url":"git@github.com:mitocw/edx-platform.git","clone_url":"https://github.com/mitocw/edx-platform.git","svn_url":"https://github.com/mitocw/edx-platform","homepage":"http://code.edx.org/","size":554421,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":76,"forks":1,"open_issues":76,"watchers":2,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"23ef9891086dd95ebd83ca5cfc231fea6fab5ead","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-11-10T10:22:31Z","pushed_at":"2015-11-10T15:40:12Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":2206278,"stargazers_count":2228,"watchers_count":2228,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1356,"mirror_url":null,"open_issues_count":136,"forks":1356,"open_issues":136,"watchers":2228,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10538"},"html":{"href":"https://github.com/edx/edx-platform/pull/10538"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/10538"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/10538/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10538/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10538/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/ee5963e9840190e2322cc7ae797b337503b159c3"}}}}