diff options
author | Christian Fehmer <[email protected]> | 2024-06-25 10:26:37 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-06-25 10:26:37 +0200 |
commit | 5da8c6ed8c9b1198279af705e2fd434cc2e7dbb4 (patch) | |
tree | 4b3d149dbf256f6493ffc7d69cd301e61186a63b | |
parent | e42f888ff1c72d72d77b45bc274c9a9fbad21fa9 (diff) | |
download | monkeytype-5da8c6ed8c9b1198279af705e2fd434cc2e7dbb4.tar.gz monkeytype-5da8c6ed8c9b1198279af705e2fd434cc2e7dbb4.zip |
fix(test activity): calendar months misalignment in some cases (#5523)
-rw-r--r-- | frontend/src/ts/elements/test-activity-calendar.ts | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/frontend/src/ts/elements/test-activity-calendar.ts b/frontend/src/ts/elements/test-activity-calendar.ts index 16b4c9c9b..9464355cd 100644 --- a/frontend/src/ts/elements/test-activity-calendar.ts +++ b/frontend/src/ts/elements/test-activity-calendar.ts @@ -72,21 +72,19 @@ export class TestActivityCalendar implements MonkeyTypes.TestActivityCalendar { start: this.startDay, end: this.endDay, }); - const results: MonkeyTypes.TestActivityMonth[] = []; for (let i = 0; i < months.length; i++) { const month: Date = months[i] as Date; - let start = - i === 0 ? new UTCDateMini(this.startDay) : startOfMonth(month); - let end = - i === months.length - 1 - ? new UTCDateMini(this.endDay) - : endOfMonth(start); - - if (!isSunday(start)) + let start = i === 0 ? this.startDay : startOfMonth(month); + let end = i === months.length - 1 ? this.endDay : endOfMonth(start); + + if (!isSunday(start)) { start = (i === 0 ? previousSunday : nextSunday)(start); - if (!isSaturday(end)) end = nextSaturday(end); + } + if (!isSaturday(end)) { + end = nextSaturday(end); + } const weeks = differenceInWeeks(end, start, { roundingMethod: "ceil" }); if (weeks > 2) { |