diff --git a/app/api/dsoc/applications/route.ts b/app/api/dsoc/applications/route.ts index a473358..bbf4beb 100644 --- a/app/api/dsoc/applications/route.ts +++ b/app/api/dsoc/applications/route.ts @@ -20,10 +20,11 @@ async function getMenteeFromToken(request: NextRequest) { function getDeadlineEnd(dateValue: string | Date) { if (dateValue instanceof Date) { + // Treat stored date-only values as UTC calendar dates so we don't cut off early in local time zones. return new Date( - dateValue.getFullYear(), - dateValue.getMonth(), - dateValue.getDate(), + dateValue.getUTCFullYear(), + dateValue.getUTCMonth(), + dateValue.getUTCDate(), 23, 59, 59, @@ -35,7 +36,7 @@ function getDeadlineEnd(dateValue: string | Date) { return new Date(dateValue as unknown as string); } - const [year, month, day] = dateValue.split('-').map(Number); + const [year, month, day] = dateValue.slice(0, 10).split('-').map(Number); if (!year || !month || !day) { return new Date(dateValue); diff --git a/app/dsoc/projects/[id]/page.tsx b/app/dsoc/projects/[id]/page.tsx index 9696f08..452f960 100644 --- a/app/dsoc/projects/[id]/page.tsx +++ b/app/dsoc/projects/[id]/page.tsx @@ -368,11 +368,23 @@ export default function ProjectDetailPage({ params }: { params: Promise<{ id: st }); }; - const getDeadlineEnd = (dateString: string) => { - const [year, month, day] = dateString.split('-').map(Number); + const getDeadlineEnd = (dateValue: string | Date) => { + if (dateValue instanceof Date) { + return new Date( + dateValue.getUTCFullYear(), + dateValue.getUTCMonth(), + dateValue.getUTCDate(), + 23, + 59, + 59, + 999 + ); + } + + const [year, month, day] = dateValue.slice(0, 10).split('-').map(Number); if (!year || !month || !day) { - return new Date(dateString); + return new Date(dateValue); } return new Date(year, month - 1, day, 23, 59, 59, 999);