Skip to content

Commit 566954e

Browse files
authored
Merge pull request #19 from reorx/copilot/fix-18
Fix YYYY date format rendering as "Jan YYYY" in HTML output
2 parents 424a921 + ca77ca8 commit 566954e

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

sample.cv.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"description": "AI-powered data optimization company",
3535
"position": "Senior Engineering Manager",
3636
"url": "http://nucleuslabs.example.com",
37-
"startDate": "2023-01",
37+
"startDate": "2023",
3838
"endDate": null,
3939
"summary": "Currently leading a team of engineers developing next-generation AI algorithms for data compression and optimization.",
4040
"highlights": [
@@ -115,7 +115,7 @@
115115
"url": "https://www.ou.edu/",
116116
"area": "Information Technology",
117117
"studyType": "Bachelor",
118-
"startDate": "2011-06-01",
118+
"startDate": "2011",
119119
"endDate": "2014-01-01",
120120
"score": "4.0",
121121
"courses": [
@@ -140,7 +140,7 @@
140140
"awards": [
141141
{
142142
"title": "Digital Compression Pioneer Award",
143-
"date": "2014-11-01",
143+
"date": "2014",
144144
"awarder": "Techcrunch",
145145
"summary": "There is no spoon."
146146
},
@@ -155,7 +155,7 @@
155155
{
156156
"name": "Video compression for 3d media",
157157
"publisher": "Hooli",
158-
"releaseDate": "2014-10-01",
158+
"releaseDate": "2014-10",
159159
"url": "http://en.wikipedia.org/wiki/Silicon_Valley_(TV_series)",
160160
"summary": "Innovative middle-out compression algorithm that changes the way we store data."
161161
},

src/themes/reorx/index.ejs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,28 @@ function dateRange(item, level) {
3333
break;
3434
}
3535
if (format) {
36-
startDate = startDate ? fn.reformatDate(startDate, format) : ''
37-
endDate = endDate ? fn.reformatDate(endDate, format) : ''
36+
// Handle YYYY-only and YYYY-MM dates
37+
if (startDate && /^\d{4}$/.test(startDate)) {
38+
// YYYY format - return as-is
39+
startDate = startDate
40+
} else if (startDate && /^\d{4}-\d{2}$/.test(startDate)) {
41+
// YYYY-MM format - format as MMM YYYY
42+
startDate = fn.reformatDate(startDate, 'MMM YYYY')
43+
} else {
44+
// Other formats (YYYY-MM-DD, etc.)
45+
startDate = startDate ? fn.reformatDate(startDate, format) : ''
46+
}
47+
48+
if (endDate && /^\d{4}$/.test(endDate)) {
49+
// YYYY format - return as-is
50+
endDate = endDate
51+
} else if (endDate && /^\d{4}-\d{2}$/.test(endDate)) {
52+
// YYYY-MM format - format as MMM YYYY
53+
endDate = fn.reformatDate(endDate, 'MMM YYYY')
54+
} else {
55+
// Other formats (YYYY-MM-DD, etc.)
56+
endDate = endDate ? fn.reformatDate(endDate, format) : ''
57+
}
3858
}
3959
let result = ''
4060
if (startDate && endDate) {
@@ -49,8 +69,8 @@ function dateRange(item, level) {
4969
%>
5070

5171
<%
52-
function date(item, level) {
53-
let {date} = item
72+
function date(item, level, fieldName = 'date') {
73+
let date = item[fieldName]
5474
if (!date) return ''
5575
let format
5676
// level: 1: year, 2: month, 3: day
@@ -63,7 +83,17 @@ function date(item, level) {
6383
break;
6484
}
6585
if (format) {
66-
date = date ? fn.reformatDate(date, format) : ''
86+
// Handle YYYY-only and YYYY-MM dates
87+
if (/^\d{4}$/.test(date)) {
88+
// YYYY format - return as-is
89+
date = date
90+
} else if (/^\d{4}-\d{2}$/.test(date)) {
91+
// YYYY-MM format - format as MMM YYYY
92+
date = fn.reformatDate(date, 'MMM YYYY')
93+
} else {
94+
// Other formats (YYYY-MM-DD, etc.)
95+
date = date ? fn.reformatDate(date, format) : ''
96+
}
6797
}
6898
return `<div class="date-range">${date}</div>`
6999
}
@@ -382,7 +412,7 @@ function date(item, level) {
382412
<div class="publication section-item">
383413
<div class="row space-between">
384414
<h3><%= item.name %></h3>
385-
<%- date(item, 2) %>
415+
<%- date(item, 2, 'releaseDate') %>
386416
</div>
387417
<div class="publisher row subtitle"><%= item.publisher %></div>
388418
<%- linkInDiv(item.url) %>

0 commit comments

Comments
 (0)