Problema sort() risolto.
Il dilemma che ora mi affligge é nascosto nel seguente codice:
codice:
var endOfMonth = 30;
if (dstMonth == 0 || dstMonth == 2 || dstMonth == 4 || dstMonth == 6 ||
dstMonth == 7 || dstMonth == 9 || dstMonth == 11) { endOfMonth = 31; }
j = dstWeekDay;
for (var i = dstMonthDay; i <= endOfMonth; i++) {
if (j == 0) { monthSundays.push(i); }
if (j == 6) { j = 0; }
else { j++; }
}
monthSundays.sort(sundaySort);
for (var k = 0; k < monthSundays.length; k++) {
var mSun = monthSundays[k];
if (dstMonth == dstBeginMonth) {
if (dstObj.beginSunday == 1) {
if (dstMonthDay >= mSun && k == 0) { return isDST; }
}
if (dstObj.beginSunday == 2) {
if (dstMonthDay >= mSun && k == 1) { return isDST; }
}
if (dstObj.beginSunday == 5) {
if (dstMonthDay >= mSun && k == (monthSundays.length -1)) { return isDST; }
}
}
if (dstMonth == dstEndMonth) {
if (dstObj.endSunday == 1) {
if (dstMonthDay <= mSun && k == 0) { return isDST; }
}
if (dstObj.endSunday == 2) {
if (dstMonthDay <= mSun && k == 1) { return isDST; }
}
if (dstObj.endSunday == 5) {
if (dstMonthDay <= mSun && k == (monthSundays.length -1)) {
return isDST;
}
}
}
}
return notDST;
}
1) Perché non c'é un dstMonth == 1 in cui endOfMonth assume valore differente da 31 e 30 quando in messico l'ora legale scatta la 3 domenica di Febbraio che nel 2010 avrà 28 giorni soltanto?
2) Perché nel ciclo 'for (var k = 0; k < monthSundays.length; k++) {' non si considera l'espressione:
'dstObj.beginSunday == 3' e 'dstObj.beginSunday == 4'?