Skip to content

Commit 54ebf53

Browse files
committed
Simplify after date transition boundaries.
When we are looking for the first day of the week greater than a certain date, we already have the start date. For some reason I was starting at the first of the month instead of just starting at the given date. I was performing the greater than or equal too in the loop, instead of just looking for the day of the week. This will throw off the seek if the first day of the week (i.e. first Friday on or after the 29th) occurs in the next month.
1 parent a2c5ac5 commit 54ebf53

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

util/transitions.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
// to create the full date in the loop, Amman says no.
1818
while ((fields = new Date(Date.UTC(year, rule.month, day))).getUTCDay() != i) day--;
1919
} else {
20-
var min = parseInt(date[4], 10);
20+
var day = parseInt(date[4], 10);
2121
for (var i = 0, stop = ABBREV.length; i < stop; i++)
2222
if (ABBREV[i] === date[3]) break;
23-
day = 1;
2423
for (;;) {
2524
fields = new Date(Date.UTC(year, rule.month, day));
26-
if (fields.getUTCDay() === i && fields.getUTCDate() >= min) break;
25+
if (fields.getUTCDay() === i) break;
2726
day++;
2827
}
2928
}

0 commit comments

Comments
 (0)