Created
November 25, 2018 11:33
-
-
Save maximelkin/4e56cdff9890e8c5a27443cfd3a6d270 to your computer and use it in GitHub Desktop.
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
const step = 24 * 60 * 60 * 1000; | |
function findMissed(values) { | |
const dates = values.map(x => new Date(x.date).getTime()); | |
const sum = dates.reduce((acc, x) => acc + x); | |
const min = Math.min(...dates); | |
return new Date((min * (dates.length + 1) + step * (dates.length + 1) * dates.length / 2) - sum).toISOString().split('T')[0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment