{"action":"created","comment":{"url":"https://api.github.com/repos/python-excel/xlrd/pulls/comments/51493809","id":51493809,"diff_hunk":"@@ -130,6 +131,76 @@ def xldate_as_datetime(xldate, datemode):\n     return epoch + datetime.timedelta(days, seconds, 0, milliseconds)\n \n \n+##\n+# Convert an Excel date/time in ISO date format into a serial number.\n+#\n+# @param xldate The Excel number\n+# @param datemode 0: 1900-based, 1: 1904-based.\n+#\n+# @return an Excel serial date number.\n+#\n+def xldate_strict_to_number(xldate, datemode):\n+    \"\"\"\n+    Convert a Excel ISO date (from Excel 2013 in strict Open XML mode)\n+    to a serial date and time.\n+\n+    \"\"\"\n+\n+    if datemode:\n+        # Excel for Mac date epoch.\n+        epoch = epoch_1904\n+    else:\n+        # Default Excel epoch.\n+        epoch = epoch_1900_minus_1\n+\n+    if re.search(\"T\", xldate):\n+        # The Excel date is in a date and time format.\n+        m = re.match(r'(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(.\\d+)',\n+                     xldate)\n+\n+        dt = datetime.datetime(\n+            int(m.group(1)),\n+            int(m.group(2)),\n+            int(m.group(3)),\n+            int(m.group(4)),\n+            int(m.group(5)),\n+            int(m.group(6)),\n+            int(float(m.group(7)) * 1E6))\n+\n+    elif re.search(\"-\", xldate):\n+        # The Excel date is in a date only format.\n+        m = re.match(r'(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)', xldate)\n+\n+        dt = datetime.datetime(\n+            int(m.group(1)),\n+            int(m.group(2)),\n+            int(m.group(3)))\n+\n+    elif re.search(\":\", xldate):\n+        # The Excel date is in a time only format.\n+        m = re.match(r'(\\d\\d):(\\d\\d):(\\d\\d)(.\\d+)', xldate)\n+\n+        dt = datetime.time(\n+            int(m.group(1)),\n+            int(m.group(2)),\n+            int(m.group(3)),\n+            int(float(m.group(4)) * 1E6))\n+\n+        dt = datetime.datetime.combine(epoch, dt)\n+\n+    else:\n+        raise XLDateError(xldate)\n+\n+    # Convert a Python datetime.datetime value to an Excel date number.\n+    delta = dt - epoch\n+    excel_date = (delta.days\n+                  + (float(delta.seconds)\n+                     + float(delta.microseconds) / 1E6)\n+                  / (60 * 60 * 24))\n+\n+    return excel_date","path":"xlrd/xldate.py","position":79,"original_position":79,"commit_id":"9945709ce6f804004fa04ff81a473a55c8d475a7","original_commit_id":"01b119345684451cefc27ece1ee648c9cfc1c39a","user":{"login":"cjw296","id":632049,"avatar_url":"https://avatars.githubusercontent.com/u/632049?v=3","gravatar_id":"","url":"https://api.github.com/users/cjw296","html_url":"https://github.com/cjw296","followers_url":"https://api.github.com/users/cjw296/followers","following_url":"https://api.github.com/users/cjw296/following{/other_user}","gists_url":"https://api.github.com/users/cjw296/gists{/gist_id}","starred_url":"https://api.github.com/users/cjw296/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjw296/subscriptions","organizations_url":"https://api.github.com/users/cjw296/orgs","repos_url":"https://api.github.com/users/cjw296/repos","events_url":"https://api.github.com/users/cjw296/events{/privacy}","received_events_url":"https://api.github.com/users/cjw296/received_events","type":"User","site_admin":false},"body":"True, but the regex approach feels flawed to me, there must be a better way?","created_at":"2016-02-01T22:43:43Z","updated_at":"2016-02-01T22:43:43Z","html_url":"https://github.com/python-excel/xlrd/pull/91#discussion_r51493809","pull_request_url":"https://api.github.com/repos/python-excel/xlrd/pulls/91","_links":{"self":{"href":"https://api.github.com/repos/python-excel/xlrd/pulls/comments/51493809"},"html":{"href":"https://github.com/python-excel/xlrd/pull/91#discussion_r51493809"},"pull_request":{"href":"https://api.github.com/repos/python-excel/xlrd/pulls/91"}}},"pull_request":{"url":"https://api.github.com/repos/python-excel/xlrd/pulls/91","id":15464932,"html_url":"https://github.com/python-excel/xlrd/pull/91","diff_url":"https://github.com/python-excel/xlrd/pull/91.diff","patch_url":"https://github.com/python-excel/xlrd/pull/91.patch","issue_url":"https://api.github.com/repos/python-excel/xlrd/issues/91","number":91,"state":"open","locked":false,"title":"Added handling for Excel Strict ISO dates.","user":{"login":"jmcnamara","id":94267,"avatar_url":"https://avatars.githubusercontent.com/u/94267?v=3","gravatar_id":"","url":"https://api.github.com/users/jmcnamara","html_url":"https://github.com/jmcnamara","followers_url":"https://api.github.com/users/jmcnamara/followers","following_url":"https://api.github.com/users/jmcnamara/following{/other_user}","gists_url":"https://api.github.com/users/jmcnamara/gists{/gist_id}","starred_url":"https://api.github.com/users/jmcnamara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmcnamara/subscriptions","organizations_url":"https://api.github.com/users/jmcnamara/orgs","repos_url":"https://api.github.com/users/jmcnamara/repos","events_url":"https://api.github.com/users/jmcnamara/events{/privacy}","received_events_url":"https://api.github.com/users/jmcnamara/received_events","type":"User","site_admin":false},"body":"Added handling for Excel files with dates in Excel Strict XML format.\r\nThis relates to issue #86.","created_at":"2014-05-03T18:29:34Z","updated_at":"2016-02-01T22:43:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"37d7d1534dc201841fb5b0b6feaa6c8932bcc017","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/python-excel/xlrd/pulls/91/commits","review_comments_url":"https://api.github.com/repos/python-excel/xlrd/pulls/91/comments","review_comment_url":"https://api.github.com/repos/python-excel/xlrd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python-excel/xlrd/issues/91/comments","statuses_url":"https://api.github.com/repos/python-excel/xlrd/statuses/9945709ce6f804004fa04ff81a473a55c8d475a7","head":{"label":"jmcnamara:strict_date","ref":"strict_date","sha":"9945709ce6f804004fa04ff81a473a55c8d475a7","user":{"login":"jmcnamara","id":94267,"avatar_url":"https://avatars.githubusercontent.com/u/94267?v=3","gravatar_id":"","url":"https://api.github.com/users/jmcnamara","html_url":"https://github.com/jmcnamara","followers_url":"https://api.github.com/users/jmcnamara/followers","following_url":"https://api.github.com/users/jmcnamara/following{/other_user}","gists_url":"https://api.github.com/users/jmcnamara/gists{/gist_id}","starred_url":"https://api.github.com/users/jmcnamara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmcnamara/subscriptions","organizations_url":"https://api.github.com/users/jmcnamara/orgs","repos_url":"https://api.github.com/users/jmcnamara/repos","events_url":"https://api.github.com/users/jmcnamara/events{/privacy}","received_events_url":"https://api.github.com/users/jmcnamara/received_events","type":"User","site_admin":false},"repo":{"id":14214093,"name":"xlrd","full_name":"jmcnamara/xlrd","owner":{"login":"jmcnamara","id":94267,"avatar_url":"https://avatars.githubusercontent.com/u/94267?v=3","gravatar_id":"","url":"https://api.github.com/users/jmcnamara","html_url":"https://github.com/jmcnamara","followers_url":"https://api.github.com/users/jmcnamara/followers","following_url":"https://api.github.com/users/jmcnamara/following{/other_user}","gists_url":"https://api.github.com/users/jmcnamara/gists{/gist_id}","starred_url":"https://api.github.com/users/jmcnamara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmcnamara/subscriptions","organizations_url":"https://api.github.com/users/jmcnamara/orgs","repos_url":"https://api.github.com/users/jmcnamara/repos","events_url":"https://api.github.com/users/jmcnamara/events{/privacy}","received_events_url":"https://api.github.com/users/jmcnamara/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jmcnamara/xlrd","description":"Library for developers to extract data from Microsoft Excel (tm) spreadsheet files","fork":true,"url":"https://api.github.com/repos/jmcnamara/xlrd","forks_url":"https://api.github.com/repos/jmcnamara/xlrd/forks","keys_url":"https://api.github.com/repos/jmcnamara/xlrd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jmcnamara/xlrd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jmcnamara/xlrd/teams","hooks_url":"https://api.github.com/repos/jmcnamara/xlrd/hooks","issue_events_url":"https://api.github.com/repos/jmcnamara/xlrd/issues/events{/number}","events_url":"https://api.github.com/repos/jmcnamara/xlrd/events","assignees_url":"https://api.github.com/repos/jmcnamara/xlrd/assignees{/user}","branches_url":"https://api.github.com/repos/jmcnamara/xlrd/branches{/branch}","tags_url":"https://api.github.com/repos/jmcnamara/xlrd/tags","blobs_url":"https://api.github.com/repos/jmcnamara/xlrd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jmcnamara/xlrd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jmcnamara/xlrd/git/refs{/sha}","trees_url":"https://api.github.com/repos/jmcnamara/xlrd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jmcnamara/xlrd/statuses/{sha}","languages_url":"https://api.github.com/repos/jmcnamara/xlrd/languages","stargazers_url":"https://api.github.com/repos/jmcnamara/xlrd/stargazers","contributors_url":"https://api.github.com/repos/jmcnamara/xlrd/contributors","subscribers_url":"https://api.github.com/repos/jmcnamara/xlrd/subscribers","subscription_url":"https://api.github.com/repos/jmcnamara/xlrd/subscription","commits_url":"https://api.github.com/repos/jmcnamara/xlrd/commits{/sha}","git_commits_url":"https://api.github.com/repos/jmcnamara/xlrd/git/commits{/sha}","comments_url":"https://api.github.com/repos/jmcnamara/xlrd/comments{/number}","issue_comment_url":"https://api.github.com/repos/jmcnamara/xlrd/issues/comments{/number}","contents_url":"https://api.github.com/repos/jmcnamara/xlrd/contents/{+path}","compare_url":"https://api.github.com/repos/jmcnamara/xlrd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jmcnamara/xlrd/merges","archive_url":"https://api.github.com/repos/jmcnamara/xlrd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jmcnamara/xlrd/downloads","issues_url":"https://api.github.com/repos/jmcnamara/xlrd/issues{/number}","pulls_url":"https://api.github.com/repos/jmcnamara/xlrd/pulls{/number}","milestones_url":"https://api.github.com/repos/jmcnamara/xlrd/milestones{/number}","notifications_url":"https://api.github.com/repos/jmcnamara/xlrd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jmcnamara/xlrd/labels{/name}","releases_url":"https://api.github.com/repos/jmcnamara/xlrd/releases{/id}","deployments_url":"https://api.github.com/repos/jmcnamara/xlrd/deployments","created_at":"2013-11-07T19:49:37Z","updated_at":"2016-01-30T15:27:06Z","pushed_at":"2016-01-30T16:34:29Z","git_url":"git://github.com/jmcnamara/xlrd.git","ssh_url":"git@github.com:jmcnamara/xlrd.git","clone_url":"https://github.com/jmcnamara/xlrd.git","svn_url":"https://github.com/jmcnamara/xlrd","homepage":"http://www.python-excel.org/","size":2907,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"python-excel:master","ref":"master","sha":"c26029b750dd4ec1de9d468e0a34bf53e6f429e5","user":{"login":"python-excel","id":1507022,"avatar_url":"https://avatars.githubusercontent.com/u/1507022?v=3","gravatar_id":"","url":"https://api.github.com/users/python-excel","html_url":"https://github.com/python-excel","followers_url":"https://api.github.com/users/python-excel/followers","following_url":"https://api.github.com/users/python-excel/following{/other_user}","gists_url":"https://api.github.com/users/python-excel/gists{/gist_id}","starred_url":"https://api.github.com/users/python-excel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-excel/subscriptions","organizations_url":"https://api.github.com/users/python-excel/orgs","repos_url":"https://api.github.com/users/python-excel/repos","events_url":"https://api.github.com/users/python-excel/events{/privacy}","received_events_url":"https://api.github.com/users/python-excel/received_events","type":"Organization","site_admin":false},"repo":{"id":3645885,"name":"xlrd","full_name":"python-excel/xlrd","owner":{"login":"python-excel","id":1507022,"avatar_url":"https://avatars.githubusercontent.com/u/1507022?v=3","gravatar_id":"","url":"https://api.github.com/users/python-excel","html_url":"https://github.com/python-excel","followers_url":"https://api.github.com/users/python-excel/followers","following_url":"https://api.github.com/users/python-excel/following{/other_user}","gists_url":"https://api.github.com/users/python-excel/gists{/gist_id}","starred_url":"https://api.github.com/users/python-excel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-excel/subscriptions","organizations_url":"https://api.github.com/users/python-excel/orgs","repos_url":"https://api.github.com/users/python-excel/repos","events_url":"https://api.github.com/users/python-excel/events{/privacy}","received_events_url":"https://api.github.com/users/python-excel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python-excel/xlrd","description":"Library for developers to extract data from Microsoft Excel (tm) spreadsheet files","fork":false,"url":"https://api.github.com/repos/python-excel/xlrd","forks_url":"https://api.github.com/repos/python-excel/xlrd/forks","keys_url":"https://api.github.com/repos/python-excel/xlrd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python-excel/xlrd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python-excel/xlrd/teams","hooks_url":"https://api.github.com/repos/python-excel/xlrd/hooks","issue_events_url":"https://api.github.com/repos/python-excel/xlrd/issues/events{/number}","events_url":"https://api.github.com/repos/python-excel/xlrd/events","assignees_url":"https://api.github.com/repos/python-excel/xlrd/assignees{/user}","branches_url":"https://api.github.com/repos/python-excel/xlrd/branches{/branch}","tags_url":"https://api.github.com/repos/python-excel/xlrd/tags","blobs_url":"https://api.github.com/repos/python-excel/xlrd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python-excel/xlrd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python-excel/xlrd/git/refs{/sha}","trees_url":"https://api.github.com/repos/python-excel/xlrd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python-excel/xlrd/statuses/{sha}","languages_url":"https://api.github.com/repos/python-excel/xlrd/languages","stargazers_url":"https://api.github.com/repos/python-excel/xlrd/stargazers","contributors_url":"https://api.github.com/repos/python-excel/xlrd/contributors","subscribers_url":"https://api.github.com/repos/python-excel/xlrd/subscribers","subscription_url":"https://api.github.com/repos/python-excel/xlrd/subscription","commits_url":"https://api.github.com/repos/python-excel/xlrd/commits{/sha}","git_commits_url":"https://api.github.com/repos/python-excel/xlrd/git/commits{/sha}","comments_url":"https://api.github.com/repos/python-excel/xlrd/comments{/number}","issue_comment_url":"https://api.github.com/repos/python-excel/xlrd/issues/comments{/number}","contents_url":"https://api.github.com/repos/python-excel/xlrd/contents/{+path}","compare_url":"https://api.github.com/repos/python-excel/xlrd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python-excel/xlrd/merges","archive_url":"https://api.github.com/repos/python-excel/xlrd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python-excel/xlrd/downloads","issues_url":"https://api.github.com/repos/python-excel/xlrd/issues{/number}","pulls_url":"https://api.github.com/repos/python-excel/xlrd/pulls{/number}","milestones_url":"https://api.github.com/repos/python-excel/xlrd/milestones{/number}","notifications_url":"https://api.github.com/repos/python-excel/xlrd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python-excel/xlrd/labels{/name}","releases_url":"https://api.github.com/repos/python-excel/xlrd/releases{/id}","deployments_url":"https://api.github.com/repos/python-excel/xlrd/deployments","created_at":"2012-03-07T04:50:48Z","updated_at":"2016-02-01T09:51:07Z","pushed_at":"2016-02-01T22:39:54Z","git_url":"git://github.com/python-excel/xlrd.git","ssh_url":"git@github.com:python-excel/xlrd.git","clone_url":"https://github.com/python-excel/xlrd.git","svn_url":"https://github.com/python-excel/xlrd","homepage":"http://www.python-excel.org/","size":3192,"stargazers_count":683,"watchers_count":683,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":170,"mirror_url":null,"open_issues_count":46,"forks":170,"open_issues":46,"watchers":683,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python-excel/xlrd/pulls/91"},"html":{"href":"https://github.com/python-excel/xlrd/pull/91"},"issue":{"href":"https://api.github.com/repos/python-excel/xlrd/issues/91"},"comments":{"href":"https://api.github.com/repos/python-excel/xlrd/issues/91/comments"},"review_comments":{"href":"https://api.github.com/repos/python-excel/xlrd/pulls/91/comments"},"review_comment":{"href":"https://api.github.com/repos/python-excel/xlrd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python-excel/xlrd/pulls/91/commits"},"statuses":{"href":"https://api.github.com/repos/python-excel/xlrd/statuses/9945709ce6f804004fa04ff81a473a55c8d475a7"}}}}