Skip to content

Instantly share code, notes, and snippets.

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 philsturgeon/226987 to your computer and use it in GitHub Desktop.
Save philsturgeon/226987 to your computer and use it in GitHub Desktop.
function getCorrectIndex(i, date)
{
// find out what day of the week it is
var day_of_the_week = date.substr(0,3);
// define what days correspond to which array indices
var days = new Object();
days.Mon = [0,5,10,15,20];
days.Tue = [1,6,11,16,21];
days.Wed = [2,7,12,17,22];
days.Thu = [3,8,13,18,23];
days.Fri = [4,9,14,19,24];
// loop through the appropriate array to find the correct index
var j = 0;
for each(var val in days[day_of_the_week])
{
if(i == val)
{
$return = days[day_of_the_week][j];
print($return);
return $return;
}
else if(i > val)
{
j++;
}
else
{
while(i < val)
{
i++;
}
$return = i;
print($return);
return $return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment