Skip to content

Commit 9bddbab

Browse files
committed
fix deadline issue
1 parent d1fef48 commit 9bddbab

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

app/api/dsoc/applications/route.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ async function getMenteeFromToken(request: NextRequest) {
2020

2121
function getDeadlineEnd(dateValue: string | Date) {
2222
if (dateValue instanceof Date) {
23+
// Treat stored date-only values as UTC calendar dates so we don't cut off early in local time zones.
2324
return new Date(
24-
dateValue.getFullYear(),
25-
dateValue.getMonth(),
26-
dateValue.getDate(),
25+
dateValue.getUTCFullYear(),
26+
dateValue.getUTCMonth(),
27+
dateValue.getUTCDate(),
2728
23,
2829
59,
2930
59,
@@ -35,7 +36,7 @@ function getDeadlineEnd(dateValue: string | Date) {
3536
return new Date(dateValue as unknown as string);
3637
}
3738

38-
const [year, month, day] = dateValue.split('-').map(Number);
39+
const [year, month, day] = dateValue.slice(0, 10).split('-').map(Number);
3940

4041
if (!year || !month || !day) {
4142
return new Date(dateValue);

app/dsoc/projects/[id]/page.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,23 @@ export default function ProjectDetailPage({ params }: { params: Promise<{ id: st
368368
});
369369
};
370370

371-
const getDeadlineEnd = (dateString: string) => {
372-
const [year, month, day] = dateString.split('-').map(Number);
371+
const getDeadlineEnd = (dateValue: string | Date) => {
372+
if (dateValue instanceof Date) {
373+
return new Date(
374+
dateValue.getUTCFullYear(),
375+
dateValue.getUTCMonth(),
376+
dateValue.getUTCDate(),
377+
23,
378+
59,
379+
59,
380+
999
381+
);
382+
}
383+
384+
const [year, month, day] = dateValue.slice(0, 10).split('-').map(Number);
373385

374386
if (!year || !month || !day) {
375-
return new Date(dateString);
387+
return new Date(dateValue);
376388
}
377389

378390
return new Date(year, month - 1, day, 23, 59, 59, 999);

0 commit comments

Comments
 (0)