diff --git a/index.php b/index.php index a74d108..fd2ad87 100644 --- a/index.php +++ b/index.php @@ -36,7 +36,7 @@ $extra_contact_links = $cvData['contact_links'] ?? []; */ // Map experience to expected structure $cv_experience = array_map(function ($e) { - return [ + return [ 'title' => $e['title'] ?? '', 'org' => $e['organization'] ?? '', 'date' => $e['date'] ?? '', @@ -44,6 +44,25 @@ $cv_experience = array_map(function ($e) { ]; }, $cvData['experience'] ?? []); +// Helper to calculate years between start and end dates +function calculateYears($dateStr) { + // Extract start and end years, support 'present' or 'current' + $matches = []; + $dateStr = str_replace(['–', '—', '−', '-'], '-', $dateStr); + $parts = array_map('trim', explode('-', $dateStr, 2)); + if (count($parts) < 2) { + return 0; + } + $start = (int)$parts[0]; + $endRaw = strtolower($parts[1]); + $end = ($endRaw === 'present' || $endRaw === 'current') ? (int)date('Y') : (int)$endRaw; + $years = $end - $start; + if ($years <= 1) { + return "1 year"; + } + return "$years years"; +} + // Map education to expected structure $cv_education = array_map(function ($e) { return [ @@ -164,7 +183,7 @@ $cv_skills = $cvData['skills'] ?? [];

- + ()

@@ -199,7 +218,7 @@ $cv_skills = $cvData['skills'] ?? [];

- + ()

@@ -342,4 +361,4 @@ $cv_skills = $cvData['skills'] ?? []; - \ No newline at end of file +