Skip to content

Instantly share code, notes, and snippets.

@ghaiklor
Created September 13, 2015 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghaiklor/2535ba18535e4c42d46e to your computer and use it in GitHub Desktop.
Save ghaiklor/2535ba18535e4c42d46e to your computer and use it in GitHub Desktop.
Script calculates developers days in year based on shifts
'use strict';
const CURRENT_YEAR = 2015;
// Generator that shifts days by bits
function* developersDayGenerator() {
let day = 1;
while (day < 365) {
yield day;
day = day << 1;
}
}
// Convert day of year to normal date
const dayToDate = day => new Date(new Date(CURRENT_YEAR, 0).setDate(day)).toDateString();
// Iterate through developers' days and convert to date
for (let day of developersDayGenerator()) {
console.log(`${(day >>> 0).toString(2)} - ${dayToDate(day)}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment