Last active
September 13, 2018 09:27
-
-
Save wentout/d56ea07f0b2bfc71d20207fa483e5acc to your computer and use it in GitHub Desktop.
Software Developer Day Holiday Check
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
global.isSoftwareDeveloperDay = function () { | |
const DEVELOPER_DAY = | |
Math.pow(2, 8); | |
const UNIX_EPOCH_BEGIN = 864e5; | |
const timestmp = new Date() | |
.setFullYear( | |
(new Date()) | |
.getFullYear(), 0, 1) | |
const yearFirstDayTS = | |
Math.floor(timestmp / UNIX_EPOCH_BEGIN); | |
const today = | |
Math.ceil((new Date() | |
.getTime()) / UNIX_EPOCH_BEGIN); | |
const dayOfYear = today - yearFirstDayTS; | |
return dayOfYear/DEVELOPER_DAY === 1; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment