Hi I'm trying to change this calendar's starting weekday from Sunday to Monday.
But I don't understand what's going on in the var k = ...
line. What is this line of code trying to say in human language?
https://codepen.io/xmark/pen/WQaXdv?editors=1010
// June 2018
var k = lastDay_of_LastMonth - firstDay_of_Month+1;
27
//_____________________________________________________________________
// TEST
var lastDay_of_LastMonth = new Date(2018, 5, 0); // May 31st 2018
document.write('Today is: ' + lastDay_of_LastMonth.toLocaleString());
// Today is: 5/31/2018, 12:00:00 AM
var firstDay_of_Month = new Date(2018, 5, 1); // June 1st 2018
firstDay_of_Month."getDay()";
5
// June 2018
var k = lastDay_of_LastMonth - firstDay_of_Month+1;
lastDay_of_LastMonth.setDate(lastDay_of_LastMonth.getDate() - 6);
document.write('<br>X days ago was: ' + lastDay_of_LastMonth.toLocaleString());
// X days ago was: 5/25/2018, 12:00:00 AM
//_____________________________________________________________________
// June 2018
27 = 31 - 5+1;
I see from this thread that this code is calculating (Date - Days), counting days backwards. But I can't understand what it is doing in human language for the calendar code. Shouldn't the math 31-(5+1) = 25
meaning it's going 6 days back in time why do I get the value 27
back?
Subtract days from a date in JavaScript