feat(app/utils, plugins): normalize dates with improved format (#573)

This commit is contained in:
Simon Lecoq
2021-10-13 22:08:31 -04:00
committed by GitHub
parent 19036b2e41
commit 662fe8de2f
16 changed files with 32 additions and 16 deletions

View File

@@ -28,7 +28,7 @@ export default async function({login, q, imports, data, computed, graphql, queri
.map(({title, unlock, ...achievement}) => ({
prefix:({S:"Master", A:"Super", B:"Great"}[achievement.rank] ?? ""),
title,
unlock:!/invalid date/i.test(unlock) ? `${imports.format.date(unlock, {timeStyle:"short"})} on ${imports.format.date(unlock, {dateStyle:"short"})}` : null,
unlock:!/invalid date/i.test(unlock) ? `${imports.format.date(unlock, {time:true})} on ${imports.format.date(unlock, {date:true})}` : null,
...achievement,
}))
.map(({icon, ...achievement}) => ({icon:icon.replace(/#primary/g, colors[achievement.rank][0]).replace(/#secondary/g, colors[achievement.rank][1]), ...achievement}))