"use client"; import type { WorkExperience as WorkExperienceType } from "../types"; interface WorkExperienceProps { experiences: WorkExperienceType[]; } function formatMonth(iso: string) { const d = new Date(iso); if (Number.isNaN(d.getTime())) return iso; return d.toLocaleDateString("en-US", { year: "numeric", month: "short", timeZone: "UTC" }); } /** "X yr Y mo" duration between two dates (toDate null = now). */ function formatDuration(fromIso: string, toIso?: string | null) { const from = new Date(fromIso); const to = toIso ? new Date(toIso) : new Date(); if (Number.isNaN(from.getTime()) || Number.isNaN(to.getTime())) return ""; let months = (to.getFullYear() - from.getFullYear()) * 12 + (to.getMonth() - from.getMonth()); if (to.getDate() >= from.getDate()) months += 1; // count the current/partial month months = Math.max(months, 1); const years = Math.floor(months / 12); const rem = months % 12; const parts: string[] = []; if (years > 0) parts.push(`${years} yr`); if (rem > 0) parts.push(`${rem} mo`); return parts.join(" "); } export function WorkExperience({ experiences }: WorkExperienceProps) { return (

Work Experience

Actual work that i did at actual companies.

{experiences.length === 0 ? (

No work experience entries available yet.

) : (
{experiences.map((entry) => (
{entry.iconUrl ? ( ) : null}

{entry.company}

{entry.role}

{formatMonth(entry.fromDate)} —{" "} {entry.toDate ? formatMonth(entry.toDate) : "Present"} · {formatDuration(entry.fromDate, entry.toDate)}

{entry.url ? ( {new URL(entry.url).hostname.replace(/^www\./, "")} ) : null}

{entry.summary}

{entry.tags.length > 0 ? (
{entry.tags.map((tag) => ( {tag} ))}
) : null}
))}
)}
); }