Skip to content

Commit

Permalink
🚸 (results) Improve submitted at field parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 5, 2024
1 parent 022a320 commit 77bc138
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/lib/results/convertResultsToTableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,19 @@ export const convertResultsToTableData = (
}, {}),
}))

const convertDateToReadable = (date: Date): string =>
date.toDateString().split(' ').slice(1, 3).join(' ') +
', ' +
date.toLocaleTimeString([], {
const convertDateToReadable = (date: Date): string => {
const isThisYear = new Date().getFullYear() === date.getFullYear()

const dateString = date.toLocaleDateString('default', {
month: 'short',
day: 'numeric',
year: isThisYear ? undefined : 'numeric', // Only show the year if it's not the current year
})

const timeString = date.toLocaleTimeString('default', {
hour: '2-digit',
minute: '2-digit',
})

return `${dateString}, ${timeString}`
}

0 comments on commit 77bc138

Please sign in to comment.