Created
October 14, 2012 16:39
-
-
Save tbergeron/3889121 to your computer and use it in GitHub Desktop.
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
function fillHeaderDates(baseDate) { | |
var today = (baseDate) ? baseDate : new Date(), | |
dayName = getDayForDate(today); | |
$('.' + dayName + 'Date').html(getDate(today)); | |
var daysRight = [], | |
daysLeft = [], | |
after = false, | |
days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']; | |
days.forEach(function(day) { | |
if (after) { | |
daysRight.push(day); | |
} else if (day === dayName) { | |
before = false; | |
} else { | |
daysLeft.push(day); | |
} | |
}); | |
daysLeft.reverse(); | |
var todayLeft = today; | |
daysLeft.forEach(function(day) { | |
todayLeft.setDate(todayLeft.getDate() -1); | |
$('.' + day + 'Date').html(getDate(todayLeft)); | |
}); | |
var todayRight = today; | |
daysRight.forEach(function(day) { | |
todayRight.setDate(todayRight.getDate() +1); | |
$('.' + day + 'Date').html(getDate(todayRight)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment