Skip to content
Merged
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
20 changes: 10 additions & 10 deletions src/components/projects/ProjectHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ import {
} from '@heroicons/react/24/outline';
import { useProjectDetailsStore } from '@/hooks/useProjectDetailsStore';
import { useCompanyStore } from '@/hooks';
import { getBCJobUrl } from '@/utils';
import { cn } from '@/utils';
import { cn, DATE_FORMAT_FULL, formatDate as formatDateUtil, getBCJobUrl } from '@/utils';
import type { BillingMode } from '@/services/bc/projectDetailsService';

/**
* Format a date string for display (e.g., "15 Jan 2025")
* Format a date string for display (e.g., "15 Jan 2025").
*
* Treats BC's null-date sentinel ("0001-..." — typically "0001-01-01") as
* unspecified. The sentinel arrives as a non-empty ISO string, so the
* empty-check alone misses it; `new Date(...).toLocaleDateString` then
* renders it as e.g. "31 Dec 1" — the timezone shift in negative-UTC zones
* flips the calendar day, and the year prints unpadded as "1".
*/
function formatDate(dateStr?: string): string {
if (!dateStr) return 'Unspecified';
if (!dateStr || dateStr.startsWith('0001-')) return 'Unspecified';
try {
const date = new Date(dateStr);
return date.toLocaleDateString('en-GB', {
day: 'numeric',
month: 'short',
year: 'numeric',
});
return formatDateUtil(dateStr, DATE_FORMAT_FULL);
} catch {
return 'Unspecified';
}
Expand Down
Loading