Skip to content

Commit

Permalink
fix: Fix setUTCMonth check being off by one (#2239)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Apr 9, 2022
1 parent 9c0db25 commit 2b7ad4d
Show file tree
Hide file tree
Showing 5 changed files with 754 additions and 517 deletions.
6 changes: 3 additions & 3 deletions std/assembly/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ export class Date {
this.setTime(i64(daysSinceEpoch(this.year, this.month, day)) * MILLIS_PER_DAY + ms);
}

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

setUTCFullYear(year: i32): void {
Expand Down
2 changes: 1 addition & 1 deletion std/assembly/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@ declare class Date {
getUTCMilliseconds(): i32;

setUTCFullYear(value: i32): void;
setUTCMonth(value: i32): void;
setUTCMonth(value: i32, day?: i32): void;
setUTCDate(value: i32): void;
setUTCHours(value: i32): void;
setUTCMinutes(value: i32): void;
Expand Down

0 comments on commit 2b7ad4d

Please sign in to comment.