Created
September 13, 2015 19:03
-
-
Save ghaiklor/2535ba18535e4c42d46e to your computer and use it in GitHub Desktop.
Script calculates developers days in year based on shifts
This file contains 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
'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