Skip to content

Commit 77131a0

Browse files
committed
Implement date parsing utility and sort experience entries by date
1 parent cda23ef commit 77131a0

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/App.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,38 @@ function SkillsSection() {
111111
);
112112
}
113113

114+
function parseDate(dateStr: string): number {
115+
// Try to extract the most recent year and month from the date string
116+
// Handles formats like "Jun 25 - Aug 25", "Nov 24 - May 25", "2024-2025", "July - Aug 2023"
117+
// Returns a comparable number: YYYYMM
118+
if (!dateStr) return 0;
119+
// Find all years (2 or 4 digits)
120+
const yearMatches = dateStr.match(/\d{4}|\d{2}/g);
121+
let year = 0;
122+
if (yearMatches) {
123+
// Use the last year found (most recent)
124+
year = parseInt(yearMatches[yearMatches.length - 1]);
125+
if (year < 100) year += 2000; // Assume 21st century for 2-digit years
126+
}
127+
// Find all months (short or long names)
128+
const monthNames = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
129+
let month = 1;
130+
const monthMatch = dateStr.toLowerCase().match(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/);
131+
if (monthMatch) {
132+
month = monthNames.indexOf(monthMatch[0]) + 1;
133+
}
134+
return year * 100 + month;
135+
}
136+
114137
function ExperienceSection() {
138+
// Sort by parsed date descending (most recent first)
139+
const sorted = [...cvData.experience].sort((a, b) => parseDate(b.date) - parseDate(a.date));
115140
return (
116141
<section id="experience" className="min-h-screen py-20 snap-start">
117142
<div className="container mx-auto px-4">
118143
<SectionTitle>Experience</SectionTitle>
119144
<div className="space-y-8 max-w-3xl mx-auto">
120-
{[...cvData.experience].reverse().map((exp, i) => (
145+
{sorted.map((exp, i) => (
121146
<div key={i} className="bg-white/5 rounded-xl p-6">
122147
<div className="flex flex-col md:flex-row md:justify-between md:items-center mb-2">
123148
<div>

0 commit comments

Comments
 (0)