diff --git a/frontend/src/routes/jobs/JobsList.tsx b/frontend/src/routes/jobs/JobsList.tsx index d1c126c..0c84f13 100644 --- a/frontend/src/routes/jobs/JobsList.tsx +++ b/frontend/src/routes/jobs/JobsList.tsx @@ -31,6 +31,15 @@ const STATUS_LABELS: Record = { const getStatusLabel = (status: string): string => STATUS_LABELS[status] || status; +// Parse date string as UTC (backend returns UTC dates without timezone indicator) +const parseUTCDate = (dateString: string): Date => { + // If the date string doesn't have timezone info, treat it as UTC + if (!dateString.endsWith('Z') && !dateString.includes('+') && !dateString.includes('-', 10)) { + return new Date(dateString + 'Z'); + } + return new Date(dateString); +}; + // Date range filter options const DATE_RANGE_OPTIONS = [ { value: '', label: 'All Time' }, @@ -178,10 +187,10 @@ export function JobsList() { const now = new Date(); if (dateRangeFilter === 'last7') { const cutoff = subDays(now, 7); - jobs = jobs.filter((job: Job) => isAfter(new Date(job.created_at), cutoff)); + jobs = jobs.filter((job: Job) => isAfter(parseUTCDate(job.created_at), cutoff)); } else if (dateRangeFilter === 'last30') { const cutoff = subDays(now, 30); - jobs = jobs.filter((job: Job) => isAfter(new Date(job.created_at), cutoff)); + jobs = jobs.filter((job: Job) => isAfter(parseUTCDate(job.created_at), cutoff)); } } @@ -197,7 +206,7 @@ export function JobsList() { comparison = (a.created_by_name || '').localeCompare(b.created_by_name || ''); break; case 'created_at': - comparison = new Date(a.created_at).getTime() - new Date(b.created_at).getTime(); + comparison = parseUTCDate(a.created_at).getTime() - parseUTCDate(b.created_at).getTime(); break; case 'status': comparison = a.status.localeCompare(b.status); @@ -786,7 +795,7 @@ export function JobsList() { {/* Date Created */} - {formatDistanceToNow(new Date(job.created_at))} ago + {formatDistanceToNow(parseUTCDate(job.created_at))} ago {/* Languages Count */}