philsturgeon (owner)

Revisions

gist: 226987 Download_button fork
public
Public Clone URL: git://gist.github.com/226987.git
Embed All Files: show embed
ridiculous "day of the month" JavaScript.js #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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;
    }
  }
  
}