Created
November 17, 2016 19:54
-
-
Save qntm/ecfcf88206f984a5fa8bcb73d6d505f9 to your computer and use it in GitHub Desktop.
Which day was the shortest?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var tai = require("t-a-i"); | |
var prevlen = undefined; | |
var prevcount = 0; | |
for(var d = Date.UTC(1961, 0, 1); d < Date.UTC(2017, 0, 1); d += 86400000) { | |
var d2 = d + 86400000; | |
var len = tai.unixToAtomic(d2) - tai.unixToAtomic(d); | |
len = Math.round(len * 10000) / 10000; | |
if(len === prevlen) { | |
prevcount += 1; | |
} else { | |
if(prevlen !== undefined) { | |
console.log(prevlen, prevcount); | |
} | |
prevlen = len; | |
prevcount = 1; | |
} | |
} | |
console.log(prevlen, prevcount); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment