Created
October 20, 2011 00:32
-
-
Save pauladam/1300092 to your computer and use it in GitHub Desktop.
Seconds till next tuesday (coffeescript)
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
| # returns seconds till next tuesday @ noon - 5 minutes | |
| exports.reckonTimeoutValue = ()-> | |
| # num days till next tuesday | |
| tuesOffset = | |
| 2 : 7 | |
| 3 : 6 | |
| 4 : 5 | |
| 5 : 4 | |
| 6 : 3 | |
| 0 : 2 | |
| 1 : 1 | |
| now = new Date() | |
| curTime = now.getTime() | |
| oneDay = 1000 * 60 * 60 * 24 | |
| daysTillNextTues = tuesOffset[now.getDay()] * oneDay | |
| nextTuesday = new Date(curTime + daysTillNextTues) | |
| nextTuesday.setHours(11) | |
| nextTuesday.setMinutes(55) | |
| return nextTuesday.getTime() - curTime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment