feat(app/utils, plugins): normalize dates with improved format (#573)
This commit is contained in:
@@ -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}))
|
||||
|
||||
@@ -120,7 +120,7 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
data.meta = {
|
||||
version:conf.package.version,
|
||||
author:conf.package.author,
|
||||
generated:imports.format.date(new Date(), {dateStyle:"short", timeStyle:"short"})
|
||||
generated:imports.format.date(new Date(), {date:true, time:true})
|
||||
}
|
||||
|
||||
//Debug flags
|
||||
|
||||
@@ -164,7 +164,7 @@ export default async function({login, imports, data, q, account}, {enabled = fal
|
||||
name:track.name,
|
||||
artist:track.artists[0].name,
|
||||
artwork:track.album.images[0].url,
|
||||
played_at:played_at ? `${imports.format.date(played_at, {timeStyle:"short"})} on ${imports.format.date(played_at, {dateStyle:"short"})}` : null,
|
||||
played_at:played_at ? `${imports.format.date(played_at, {time:true})} on ${imports.format.date(played_at, {date:true})}` : null,
|
||||
}))
|
||||
//Ensure no duplicate are added
|
||||
for (const track of loaded) {
|
||||
|
||||
@@ -89,7 +89,7 @@ const format = {
|
||||
accepted,
|
||||
comments,
|
||||
author,
|
||||
created:imports.format.date(creation_date * 1000, {dateStyle:"short"}),
|
||||
created:imports.format.date(creation_date * 1000, {date:true}),
|
||||
link,
|
||||
id,
|
||||
question_id,
|
||||
@@ -136,7 +136,7 @@ const format = {
|
||||
comments,
|
||||
views,
|
||||
author,
|
||||
created:imports.format.date(creation_date * 1000, {dateStyle:"short"}),
|
||||
created:imports.format.date(creation_date * 1000, {date:true}),
|
||||
link,
|
||||
id,
|
||||
accepted_answer_id,
|
||||
|
||||
@@ -69,7 +69,7 @@ export default async function({login, imports, data, q, account}, {enabled = fal
|
||||
|
||||
//Format text
|
||||
console.debug(`metrics/compute/${login}/plugins > tweets > formatting tweet ${tweet.id}`)
|
||||
tweet.createdAt = `${imports.format.date(tweet.created_at, {timeStyle:"short"})} on ${imports.format.date(tweet.created_at, {dateStyle:"short"})}`
|
||||
tweet.createdAt = `${imports.format.date(tweet.created_at, {time:true})} on ${imports.format.date(tweet.created_at, {date:true})}`
|
||||
tweet.text = imports.htmlescape(
|
||||
//Escape tags
|
||||
imports.htmlescape(tweet.text, {"<":true, ">":true})
|
||||
|
||||
Reference in New Issue
Block a user