Fix date formatting to use UTC

This commit is contained in:
Deluan
2023-05-24 14:47:51 -04:00
parent e38a690632
commit ba067667c9
6 changed files with 38 additions and 38 deletions
+14
View File
@@ -24,3 +24,17 @@ export const formatDuration = (d) => {
return `${days > 0 ? days + ':' : ''}${f}`
}
export const formatFullDate = (date) => {
const dashes = date.split('-').length - 1
let options = {
year: 'numeric',
timeZone: 'UTC',
...(dashes > 0 && { month: 'short' }),
...(dashes > 1 && { day: 'numeric' }),
}
if (dashes > 2 || (dashes === 0 && date.length > 4)) {
return ''
}
return new Date(date).toLocaleDateString(undefined, options)
}