Skip to content

Commit 2b7ad4d

Browse files
authored
fix: Fix setUTCMonth check being off by one (#2239)
1 parent 9c0db25 commit 2b7ad4d

File tree

5 files changed

+754
-517
lines changed

5 files changed

+754
-517
lines changed

std/assembly/date.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ export class Date {
168168
this.setTime(i64(daysSinceEpoch(this.year, this.month, day)) * MILLIS_PER_DAY + ms);
169169
}
170170

171-
setUTCMonth(month: i32): void {
172-
if (this.month == month) return;
171+
setUTCMonth(month: i32, day: i32 = this.day): void {
172+
if (this.month == month + 1) return;
173173
var ms = euclidRem(this.epochMillis, MILLIS_PER_DAY);
174-
this.setTime(i64(daysSinceEpoch(this.year, month + 1, this.day)) * MILLIS_PER_DAY + ms);
174+
this.setTime(i64(daysSinceEpoch(this.year, month + 1, day)) * MILLIS_PER_DAY + ms);
175175
}
176176

177177
setUTCFullYear(year: i32): void {

std/assembly/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,7 @@ declare class Date {
18871887
getUTCMilliseconds(): i32;
18881888

18891889
setUTCFullYear(value: i32): void;
1890-
setUTCMonth(value: i32): void;
1890+
setUTCMonth(value: i32, day?: i32): void;
18911891
setUTCDate(value: i32): void;
18921892
setUTCHours(value: i32): void;
18931893
setUTCMinutes(value: i32): void;

0 commit comments

Comments
 (0)