Last active
September 14, 2017 08:43
-
-
Save Dafrok/693817dd6ad3656c71b1f17b9d51fe83 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function timeDec(t1, t2) { | |
const DAY = 24 * 60 * 60 * 1000 | |
const SPACING = DAY * 7 / 24 | |
const t = d => ((r = new Date(d), (22<= r < 6) ? new Date(r.setHours(22)) : r >= 0 ? new Date(r - DAY) : new Date(r)).getTime()) | |
const dec = t(t1) - t(t2) | |
return Math.abs(dec- ((dec / DAY) | 0) * SPACING) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment