Skip to content

Commit b5eb397

Browse files
committed
uxdy: Fix month being off by 1 in the date selector button
1 parent ebfc605 commit b5eb397

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

classrooms/components/date-time/DateTimeButton.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ export function DateTimeButton ({
3636
<p class='showing-schedule-wrapper'>
3737
<span class='showing-schedule-text'>Showing schedule for</span>
3838
<div class='date-time'>
39-
{dateFormat.format(
40-
new Date(date.year, date.month, date.date, time.hour, time.minute)
41-
)}
39+
{dateFormat.format(date.toLocal(time.hour, time.minute))}
4240
</div>
4341
{current && (
4442
<span class='quarter-week'>

util/Day.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class Day {
2323
return this.#date.getUTCFullYear()
2424
}
2525

26+
/** 1-indexed. */
2627
get month (): number {
2728
return this.#date.getUTCMonth() + 1
2829
}
@@ -115,10 +116,11 @@ export class Day {
115116
}
116117

117118
/**
118-
* Converts the Date to the date in local time at the start of the day.
119+
* Converts the Date to the date in local time. If time is not specified, it
120+
* defaults to midnight at the start of the day.
119121
*/
120-
toLocal (): Date {
121-
return new Date(this.year, this.month - 1, this.date)
122+
toLocal (hour = 0, minute = 0): Date {
123+
return new Date(this.year, this.month - 1, this.date, hour, minute)
122124
}
123125

124126
/**

0 commit comments

Comments
 (0)