Created
November 5, 2009 11:15
-
-
Save philsturgeon/226987 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 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