Skip to content

Instantly share code, notes, and snippets.

@wentout
Last active September 13, 2018 09:27
Show Gist options
  • Save wentout/d56ea07f0b2bfc71d20207fa483e5acc to your computer and use it in GitHub Desktop.
Save wentout/d56ea07f0b2bfc71d20207fa483e5acc to your computer and use it in GitHub Desktop.
Software Developer Day Holiday Check
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