{"action":"created","comment":{"url":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/comments/172903011","pull_request_review_id":101912136,"id":172903011,"diff_hunk":"@@ -74,25 +74,15 @@ function req(url) {\n  * @param {string} format Format string\n  * @return {string}\n  */\n-function formatTime(ts90k, format = 'YYYY-MM-DDTHH:mm:ss.SSSSSZ') {\n+function formatTime(ts90k, format = 'YYYY-MM-DDTHH:mm:ss:FFFFFFZ') {\n   const ms = ts90k / 90.0;\n   let msRound = 0.5;\n-  // Check if format string requires subsecond precision beyond ms\n-  const matches = format.match(/(S+)/);\n-  if (matches && (matches[1].length > 3)) {\n-    // Determine portion not handled by moment, which uses ms\n-    const fracms = ts90k % 90000; // Fractional ms, 90k units\n-    console.log('fracms: ' + fracms);\n-    if (fracms >= 0.001) { // Nothing extra needed if fraction is < 1 µs\n-      const subFmt = matches[1];\n-      const extraLen = Math.min(subFmt.length - 3, 3); // µs precision\n-      const fracµs = fracms / 0.09 + // µs units\n-        (0.0 * Math.pow(10, (3 - extraLen))); // and rounding\n-      const newSubFmt = subFmt.substr(0, 3) +\n-        String(1000000 + fracµs).substr(4, extraLen);\n-      format = format.replace(subFmt, newSubFmt);\n-      msRound = 0;\n-    }\n+  const fractionFormat = 'FFFFF';\n+  const fmtRegex = new RegExp('(' + fractionFormat + ')', 'g');","path":"ui-src/index.js","position":null,"original_position":25,"commit_id":"81fd27be0a8666f4405ecd00a7f9c3318b4c9a15","original_commit_id":"81fd27be0a8666f4405ecd00a7f9c3318b4c9a15","user":{"login":"scottlamb","id":8949524,"avatar_url":"https://avatars3.githubusercontent.com/u/8949524?v=4","gravatar_id":"","url":"https://api.github.com/users/scottlamb","html_url":"https://github.com/scottlamb","followers_url":"https://api.github.com/users/scottlamb/followers","following_url":"https://api.github.com/users/scottlamb/following{/other_user}","gists_url":"https://api.github.com/users/scottlamb/gists{/gist_id}","starred_url":"https://api.github.com/users/scottlamb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottlamb/subscriptions","organizations_url":"https://api.github.com/users/scottlamb/orgs","repos_url":"https://api.github.com/users/scottlamb/repos","events_url":"https://api.github.com/users/scottlamb/events{/privacy}","received_events_url":"https://api.github.com/users/scottlamb/received_events","type":"User","site_admin":false},"body":"I haven't benchmarked this, but I think it compiles the regular expression every time formatTime is run. regex compilation is quite slow (typically orders of magnitude slower than matching).\r\n\r\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions suggests using\r\n\r\nconst fmtRegex = /(FFFFF)/;\r\n\r\n(the 'g' modifier doesn't do anything; you're only looking once.)","created_at":"2018-03-07T16:33:30Z","updated_at":"2018-03-07T16:43:46Z","html_url":"https://github.com/scottlamb/moonfire-nvr/pull/18#discussion_r172903011","pull_request_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/18","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/comments/172903011"},"html":{"href":"https://github.com/scottlamb/moonfire-nvr/pull/18#discussion_r172903011"},"pull_request":{"href":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/18","id":172651856,"html_url":"https://github.com/scottlamb/moonfire-nvr/pull/18","diff_url":"https://github.com/scottlamb/moonfire-nvr/pull/18.diff","patch_url":"https://github.com/scottlamb/moonfire-nvr/pull/18.patch","issue_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/issues/18","number":18,"state":"open","locked":false,"title":"Fix time formatting for 90k unit timestamps.","user":{"login":"dolfs","id":1332437,"avatar_url":"https://avatars1.githubusercontent.com/u/1332437?v=4","gravatar_id":"","url":"https://api.github.com/users/dolfs","html_url":"https://github.com/dolfs","followers_url":"https://api.github.com/users/dolfs/followers","following_url":"https://api.github.com/users/dolfs/following{/other_user}","gists_url":"https://api.github.com/users/dolfs/gists{/gist_id}","starred_url":"https://api.github.com/users/dolfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dolfs/subscriptions","organizations_url":"https://api.github.com/users/dolfs/orgs","repos_url":"https://api.github.com/users/dolfs/repos","events_url":"https://api.github.com/users/dolfs/events{/privacy}","received_events_url":"https://api.github.com/users/dolfs/received_events","type":"User","site_admin":false},"body":"* Original code misses a 0.9 factor in scaling, producing incorrect\r\n  values in the decimal fractions.\r\n* Original would produce excess digits if timestamp was non-interger\r\n* New version can accept a format string, more flexible, but default\r\n  format string gives result identical to original","created_at":"2018-03-03T05:35:59Z","updated_at":"2018-03-07T16:43:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e528bf512d59d89765133139a2f654f25276c386","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/18/commits","review_comments_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/18/comments","review_comment_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/issues/18/comments","statuses_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/statuses/81fd27be0a8666f4405ecd00a7f9c3318b4c9a15","head":{"label":"dolfs:fixts90k","ref":"fixts90k","sha":"81fd27be0a8666f4405ecd00a7f9c3318b4c9a15","user":{"login":"dolfs","id":1332437,"avatar_url":"https://avatars1.githubusercontent.com/u/1332437?v=4","gravatar_id":"","url":"https://api.github.com/users/dolfs","html_url":"https://github.com/dolfs","followers_url":"https://api.github.com/users/dolfs/followers","following_url":"https://api.github.com/users/dolfs/following{/other_user}","gists_url":"https://api.github.com/users/dolfs/gists{/gist_id}","starred_url":"https://api.github.com/users/dolfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dolfs/subscriptions","organizations_url":"https://api.github.com/users/dolfs/orgs","repos_url":"https://api.github.com/users/dolfs/repos","events_url":"https://api.github.com/users/dolfs/events{/privacy}","received_events_url":"https://api.github.com/users/dolfs/received_events","type":"User","site_admin":false},"repo":{"id":51281289,"name":"moonfire-nvr","full_name":"dolfs/moonfire-nvr","owner":{"login":"dolfs","id":1332437,"avatar_url":"https://avatars1.githubusercontent.com/u/1332437?v=4","gravatar_id":"","url":"https://api.github.com/users/dolfs","html_url":"https://github.com/dolfs","followers_url":"https://api.github.com/users/dolfs/followers","following_url":"https://api.github.com/users/dolfs/following{/other_user}","gists_url":"https://api.github.com/users/dolfs/gists{/gist_id}","starred_url":"https://api.github.com/users/dolfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dolfs/subscriptions","organizations_url":"https://api.github.com/users/dolfs/orgs","repos_url":"https://api.github.com/users/dolfs/repos","events_url":"https://api.github.com/users/dolfs/events{/privacy}","received_events_url":"https://api.github.com/users/dolfs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dolfs/moonfire-nvr","description":"Moonfire NVR, a security camera network video recorder","fork":true,"url":"https://api.github.com/repos/dolfs/moonfire-nvr","forks_url":"https://api.github.com/repos/dolfs/moonfire-nvr/forks","keys_url":"https://api.github.com/repos/dolfs/moonfire-nvr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dolfs/moonfire-nvr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dolfs/moonfire-nvr/teams","hooks_url":"https://api.github.com/repos/dolfs/moonfire-nvr/hooks","issue_events_url":"https://api.github.com/repos/dolfs/moonfire-nvr/issues/events{/number}","events_url":"https://api.github.com/repos/dolfs/moonfire-nvr/events","assignees_url":"https://api.github.com/repos/dolfs/moonfire-nvr/assignees{/user}","branches_url":"https://api.github.com/repos/dolfs/moonfire-nvr/branches{/branch}","tags_url":"https://api.github.com/repos/dolfs/moonfire-nvr/tags","blobs_url":"https://api.github.com/repos/dolfs/moonfire-nvr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dolfs/moonfire-nvr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dolfs/moonfire-nvr/git/refs{/sha}","trees_url":"https://api.github.com/repos/dolfs/moonfire-nvr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dolfs/moonfire-nvr/statuses/{sha}","languages_url":"https://api.github.com/repos/dolfs/moonfire-nvr/languages","stargazers_url":"https://api.github.com/repos/dolfs/moonfire-nvr/stargazers","contributors_url":"https://api.github.com/repos/dolfs/moonfire-nvr/contributors","subscribers_url":"https://api.github.com/repos/dolfs/moonfire-nvr/subscribers","subscription_url":"https://api.github.com/repos/dolfs/moonfire-nvr/subscription","commits_url":"https://api.github.com/repos/dolfs/moonfire-nvr/commits{/sha}","git_commits_url":"https://api.github.com/repos/dolfs/moonfire-nvr/git/commits{/sha}","comments_url":"https://api.github.com/repos/dolfs/moonfire-nvr/comments{/number}","issue_comment_url":"https://api.github.com/repos/dolfs/moonfire-nvr/issues/comments{/number}","contents_url":"https://api.github.com/repos/dolfs/moonfire-nvr/contents/{+path}","compare_url":"https://api.github.com/repos/dolfs/moonfire-nvr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dolfs/moonfire-nvr/merges","archive_url":"https://api.github.com/repos/dolfs/moonfire-nvr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dolfs/moonfire-nvr/downloads","issues_url":"https://api.github.com/repos/dolfs/moonfire-nvr/issues{/number}","pulls_url":"https://api.github.com/repos/dolfs/moonfire-nvr/pulls{/number}","milestones_url":"https://api.github.com/repos/dolfs/moonfire-nvr/milestones{/number}","notifications_url":"https://api.github.com/repos/dolfs/moonfire-nvr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dolfs/moonfire-nvr/labels{/name}","releases_url":"https://api.github.com/repos/dolfs/moonfire-nvr/releases{/id}","deployments_url":"https://api.github.com/repos/dolfs/moonfire-nvr/deployments","created_at":"2016-02-08T05:44:49Z","updated_at":"2018-03-05T23:04:28Z","pushed_at":"2018-03-07T07:14:53Z","git_url":"git://github.com/dolfs/moonfire-nvr.git","ssh_url":"git@github.com:dolfs/moonfire-nvr.git","clone_url":"https://github.com/dolfs/moonfire-nvr.git","svn_url":"https://github.com/dolfs/moonfire-nvr","homepage":null,"size":1296,"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":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scottlamb:master","ref":"master","sha":"0d69f4f49bab80eefb820e95f21e8af85967cbf7","user":{"login":"scottlamb","id":8949524,"avatar_url":"https://avatars3.githubusercontent.com/u/8949524?v=4","gravatar_id":"","url":"https://api.github.com/users/scottlamb","html_url":"https://github.com/scottlamb","followers_url":"https://api.github.com/users/scottlamb/followers","following_url":"https://api.github.com/users/scottlamb/following{/other_user}","gists_url":"https://api.github.com/users/scottlamb/gists{/gist_id}","starred_url":"https://api.github.com/users/scottlamb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottlamb/subscriptions","organizations_url":"https://api.github.com/users/scottlamb/orgs","repos_url":"https://api.github.com/users/scottlamb/repos","events_url":"https://api.github.com/users/scottlamb/events{/privacy}","received_events_url":"https://api.github.com/users/scottlamb/received_events","type":"User","site_admin":false},"repo":{"id":48900514,"name":"moonfire-nvr","full_name":"scottlamb/moonfire-nvr","owner":{"login":"scottlamb","id":8949524,"avatar_url":"https://avatars3.githubusercontent.com/u/8949524?v=4","gravatar_id":"","url":"https://api.github.com/users/scottlamb","html_url":"https://github.com/scottlamb","followers_url":"https://api.github.com/users/scottlamb/followers","following_url":"https://api.github.com/users/scottlamb/following{/other_user}","gists_url":"https://api.github.com/users/scottlamb/gists{/gist_id}","starred_url":"https://api.github.com/users/scottlamb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottlamb/subscriptions","organizations_url":"https://api.github.com/users/scottlamb/orgs","repos_url":"https://api.github.com/users/scottlamb/repos","events_url":"https://api.github.com/users/scottlamb/events{/privacy}","received_events_url":"https://api.github.com/users/scottlamb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/scottlamb/moonfire-nvr","description":"Moonfire NVR, a security camera network video recorder","fork":false,"url":"https://api.github.com/repos/scottlamb/moonfire-nvr","forks_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/forks","keys_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/teams","hooks_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/hooks","issue_events_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/issues/events{/number}","events_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/events","assignees_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/assignees{/user}","branches_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/branches{/branch}","tags_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/tags","blobs_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/git/refs{/sha}","trees_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/statuses/{sha}","languages_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/languages","stargazers_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/stargazers","contributors_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/contributors","subscribers_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/subscribers","subscription_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/subscription","commits_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/commits{/sha}","git_commits_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/git/commits{/sha}","comments_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/comments{/number}","issue_comment_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/issues/comments{/number}","contents_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/contents/{+path}","compare_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/merges","archive_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/downloads","issues_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/issues{/number}","pulls_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls{/number}","milestones_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/milestones{/number}","notifications_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/labels{/name}","releases_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/releases{/id}","deployments_url":"https://api.github.com/repos/scottlamb/moonfire-nvr/deployments","created_at":"2016-01-02T06:05:42Z","updated_at":"2018-03-07T11:38:18Z","pushed_at":"2018-03-07T12:51:55Z","git_url":"git://github.com/scottlamb/moonfire-nvr.git","ssh_url":"git@github.com:scottlamb/moonfire-nvr.git","clone_url":"https://github.com/scottlamb/moonfire-nvr.git","svn_url":"https://github.com/scottlamb/moonfire-nvr","homepage":null,"size":1638,"stargazers_count":30,"watchers_count":30,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":9,"open_issues":9,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/18"},"html":{"href":"https://github.com/scottlamb/moonfire-nvr/pull/18"},"issue":{"href":"https://api.github.com/repos/scottlamb/moonfire-nvr/issues/18"},"comments":{"href":"https://api.github.com/repos/scottlamb/moonfire-nvr/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scottlamb/moonfire-nvr/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/scottlamb/moonfire-nvr/statuses/81fd27be0a8666f4405ecd00a7f9c3318b4c9a15"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"scottlamb"}}