I'm attempting to write a script that changes the background color of each column containing a weekend date. For some reason, the script gets thrown off for the month of March and I have no idea why. 

For purposes of debugging, I limited the script to only change Sundays. Here is what I know: 

1. Script loops through each column in sequential order as expected without skipping a column (col 2 - col 85)
2. Script colors the wrong dates in March
3. March 8 appears to be the culprit
	* it reads the date 3/8, correctly as a Sunday, but it also reads the following
	Monday (3/9) as "Sun Mar 08" instead of "Mon Mar 09". So it
	reads both Sunday (3/8) and Monday (3/9) as "Sun Mar 08".
	* dates remain off by 1 for the rest of March
4. "Sun Apr 05" gets skipped all together - goes from "Sat Apr 04" to "Mon Apr 06"
5. Dates resume as expected on "Mon Apr 06"
6. Happens to 2019 dates as well (dates off by one starting the 2nd Sunday in March to the 2nd Sunday in April)

I'm 100% perplexed. I've googled endlessly and tried so many things to no avail! Anyone have a clue what I'm missing or doing incorrectly?! Any help would be greatly appreciated!

Here's the script: 

```
//Change column background color for weekend dates

function colorAll() {

  var sheet = SpreadsheetApp.getActiveSheet();
  var startCol = 2;  //start with column B
  var endCol = sheet.getLastColumn();  // find last column in the sheet

  for (var c = startCol; c <= endCol; c++) { //loop through columns
    colorCol(c);
  }
}

//Change background color for each column passed to 'c'
function colorCol(c) {

  var sheet = SpreadsheetApp.getActiveSheet();
  var dataRange = sheet.getRange(1, c, 5, 1); //row 1, column "c", selection size = 5 rows by 1 column

  var data = dataRange.getValues();
  var col = data[0];

  var date = new Date(col); 
  var dayOfWeek = date.getDay();

//Logs values being passed to each variable in order to help debug process
  Logger.log("*** Processing column number: " + c + " now ***");
  Logger.log(col);
  Logger.log(date); 
  Logger.log(dayOfWeek);

  //If the day of week is Sunday:
  if (dayOfWeek == 0) {
      dataRange.setBackground("#E8E8E8");  //set weekends to grey
    } else {
      dataRange.setBackground("#ffffff");  //set non-weekends to white
    }

//  //If day of week is Sat or Sun:
//  if (dayOfWeek == 0 || dayOfWeek == 6) {
//    if (col[0] === "") {
//      dataRange.setBackgroundRGB(255, 255, 255);
//    } else {
//      dataRange.setBackground("#E8E8E8");
//    }
//  }

}

```

I put together the following [google sheet](https://docs.google.com/spreadsheets/d/15u3oJApl5RlN_xdCeClF1liYa-l99f9zqmejj4QmLAE/edit?usp=sharing) for testing. Permissions are set so anyone with the link can edit so have at it :)  

By double clicking B1, you can choose whatever start day you want. The bottom 3 rows return the week day number as read by sheets (1-7), the week day number as read by apps script (0-6), and the corresponding number for each column (B=2, C=3, etc).

Also, in case it helps... 

**Latest log for the dates surrounding March 8**  

expected date pattern = 6, 0, 1, 2, 3  

returned date pattern = 6, 0, 0, 1, 2

```
[20-03-10 10:13:05:886 PDT] ***Processing column number: 7 now***   
[20-03-10 10:13:05:887 PDT] [Sat Mar 07 00:00:00 GMT-06:00 2020]
[20-03-10 10:13:05:888 PDT] Sat Mar 07 00:00:00 GMT-06:00 2020
[20-03-10 10:13:05:890 PDT] 6.0
[20-03-10 10:13:06:207 PDT] *** Processing column number: 8 now ***
[20-03-10 10:13:06:209 PDT] [Sun Mar 08 00:00:00 GMT-06:00 2020]
[20-03-10 10:13:06:211 PDT] Sun Mar 08 00:00:00 GMT-06:00 2020
[20-03-10 10:13:06:212 PDT] 0.0
[20-03-10 10:13:06:555 PDT] *** Processing column number: 9 now ***
[20-03-10 10:13:06:558 PDT] [Sun Mar 08 23:00:00 GMT-06:00 2020]
[20-03-10 10:13:06:561 PDT] Sun Mar 08 23:00:00 GMT-06:00 2020
[20-03-10 10:13:06:563 PDT] 0.0
[20-03-10 10:13:06:915 PDT] *** Processing column number: 10 now ***
[20-03-10 10:13:06:917 PDT] [Mon Mar 09 23:00:00 GMT-06:00 2020]
[20-03-10 10:13:06:918 PDT] Mon Mar 09 23:00:00 GMT-06:00 2020
[20-03-10 10:13:06:920 PDT] 1.0
[20-03-10 10:13:07:343 PDT] *** Processing column number: 11 now ***
[20-03-10 10:13:07:345 PDT] [Tue Mar 10 23:00:00 GMT-06:00 2020]
[20-03-10 10:13:07:347 PDT] Tue Mar 10 23:00:00 GMT-06:00 2020
[20-03-10 10:13:07:348 PDT] 2.0

```

**Log for the dates surrounding April 5**  

expected date pattern = 5, 6, 0, 1  

returned date pattern = 5, 6, 1, 2 

```
[20-03-10 10:13:15:446 PDT] *** Processing column number: 35 now ***
[20-03-10 10:13:15:447 PDT] [Fri Apr 03 23:00:00 GMT-06:00 2020]
[20-03-10 10:13:15:449 PDT] Fri Apr 03 23:00:00 GMT-06:00 2020
[20-03-10 10:13:15:450 PDT] 5.0
[20-03-10 10:13:16:032 PDT] *** Processing column number: 36 now ***
[20-03-10 10:13:16:036 PDT] [Sat Apr 04 23:00:00 GMT-06:00 2020]
[20-03-10 10:13:16:038 PDT] Sat Apr 04 23:00:00 GMT-06:00 2020
[20-03-10 10:13:16:039 PDT] 6.0
[20-03-10 10:13:16:334 PDT] *** Processing column number: 37 now ***
[20-03-10 10:13:16:336 PDT] [Mon Apr 06 00:00:00 GMT-05:00 2020]
[20-03-10 10:13:16:338 PDT] Mon Apr 06 00:00:00 GMT-05:00 2020
[20-03-10 10:13:16:339 PDT] 1.0
[20-03-10 10:13:16:652 PDT] *** Processing column number: 38 now ***
[20-03-10 10:13:16:658 PDT] [Tue Apr 07 00:00:00 GMT-05:00 2020]
[20-03-10 10:13:16:678 PDT] Tue Apr 07 00:00:00 GMT-05:00 2020
[20-03-10 10:13:16:684 PDT] 2.0

```

Thank you in advance for your time and help! 

**UPDATE:** Adding screenshot of the aforementioned google sheet for reference  

[debugScript\_colorAll screenshot](https://i.stack.imgur.com/0MkpN.jpg) 

*(note: it says I'm not allowed to embed images yet since I am a new user. Apparently a link to the image is the best I can do. Sorry Cooper)*