I’m having real trouble working out whether JavaScript’s getDay() method (http://www.w3schools.com/jsref/jsref_getday.asp) complies with ISO 8601.
getDay() returns 0 for Sunday, 1 for Monday etc..
The documentation recommends mapping to day names like this:
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
...
var n = weekday[(new Date()).getDay()];
I can only see that the ISO standard defines Monday as the first day of the week. I would assume this means Monday should be 0, not Sunday.
Does anyone have any experience with this? Can you clarify and would you recommend overriding the method to make Monday the first day of the week?
How the weekdays are represented only matters if you want to use a date format where the weekday actually is represented as a number, e.g. the
YYYY-Www-Dformat, or if you want to get the week number for a specific date.Otherwise it doesn’t matter how the weekdays are represented numerically. A monday is still a monday.