Last active
March 22, 2019 09:51
-
-
Save dei-biz/90f8c4de8177dce1e142a0a29099a0bb to your computer and use it in GitHub Desktop.
Every15minutes
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
| //Superseded by https://gist.github.com/dei-biz/112c3825b5752c76dcb0a915b49bca47 | |
| executeNext15 = (callback)=>{ | |
| const now = new Date(); | |
| const nextTime = new Date(now.getTime() + 15 * 60 * 1000 + 1); | |
| const nextTimeRound = new Date(nextTime | |
| .setMinutes(15*(Math.floor((nextTime.getMinutes() / 60) * 4)))) //every 15 minutes/4 times an hour | |
| .setSeconds(0) | |
| const timeout = nextTimeRound - now; | |
| console.log(`Releasing the Kraken (again) at ${new Date(nextTimeRound)}`); | |
| setTimeout(()=>{ | |
| callback(); | |
| executeNext15(callback); | |
| }, timeout) | |
| } | |
| executeNext15(() => {console.log("RELEASED!")}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment