Skip to content

Commit f24c535

Browse files
committed
Use CT for sorting events
1 parent a7ab941 commit f24c535

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/app/resources/calendar/page.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ const fullFormat = new Intl.DateTimeFormat('en-US', {
4343
timeZone: 'America/Chicago',
4444
});
4545

46+
const getDateNumber = new Intl.DateTimeFormat('en-US', {
47+
day: 'numeric',
48+
timeZone: 'America/Chicago',
49+
});
50+
51+
const getMonthNumber = new Intl.DateTimeFormat('en-US', {
52+
month: 'numeric',
53+
timeZone: 'America/Chicago',
54+
});
55+
56+
const getYearNumber = new Intl.DateTimeFormat('en-US', {
57+
year: 'numeric',
58+
timeZone: 'America/Chicago',
59+
});
60+
4661
interface EventReactProps {
4762
name: string;
4863
start: string;
@@ -144,7 +159,7 @@ export default async function Calendar() {
144159
}
145160

146161
const start = new Date(event.start.dateTime);
147-
const year = start.getFullYear();
162+
const year = getYearNumber.format(start);
148163
if (lastYear !== year && !firstYear) {
149164
labelsAndEvents.push(
150165
<h2 key={year} className="text-5xl font-bold">
@@ -157,7 +172,7 @@ export default async function Calendar() {
157172
lastYear = year;
158173
firstYear = false;
159174
}
160-
const month = start.getMonth();
175+
const month = getMonthNumber.format(start);
161176
if (lastMonth !== month) {
162177
labelsAndEvents.push(
163178
<h3 key={String(year) + String(month)} className="text-4xl font-semibold">
@@ -166,7 +181,7 @@ export default async function Calendar() {
166181
);
167182
lastMonth = month;
168183
}
169-
const day = start.getDay();
184+
const day = getDateNumber.format(start);
170185
if (lastDay !== day) {
171186
labelsAndEvents.push(
172187
<h4 key={fullFormat.format(start)} className="text-3xl font-medium">

0 commit comments

Comments
 (0)