Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/api/dsoc/applications/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
18 changes: 15 additions & 3 deletions app/dsoc/projects/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading