diff --git a/src/common/model/player/impl/scoresaber-player.ts b/src/common/model/player/impl/scoresaber-player.ts index 41bd0bf..3e700d0 100644 --- a/src/common/model/player/impl/scoresaber-player.ts +++ b/src/common/model/player/impl/scoresaber-player.ts @@ -4,7 +4,7 @@ import { PlayerHistory } from "@/common/player/player-history"; import { config } from "../../../../../config"; import ky from "ky"; import { - formatDate, + formatDateMinimal, getDaysAgoDate, getMidnightAlignedDate, } from "@/common/time-utils"; @@ -88,7 +88,7 @@ export async function getScoreSaberPlayerFromToken( } if (history) { // Use the latest data for today - history[formatDate(getMidnightAlignedDate(new Date()))] = { + history[formatDateMinimal(getMidnightAlignedDate(new Date()))] = { rank: token.rank, countryRank: token.countryRank, pp: token.pp, diff --git a/src/common/schema/player-schema.ts b/src/common/schema/player-schema.ts index 925c32f..3ec91b2 100644 --- a/src/common/schema/player-schema.ts +++ b/src/common/schema/player-schema.ts @@ -1,6 +1,6 @@ import mongoose, { Document, Schema } from "mongoose"; import { PlayerHistory } from "@/common/player/player-history"; -import { formatDate, getMidnightAlignedDate } from "@/common/time-utils"; +import { formatDateMinimal, getMidnightAlignedDate } from "@/common/time-utils"; import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player"; // Interface for Player Document @@ -70,7 +70,9 @@ PlayerSchema.methods.getLastTracked = function (): Date { PlayerSchema.methods.getHistory = function (date: Date): PlayerHistory { return ( - this.statisticHistory.get(formatDate(getMidnightAlignedDate(date))) || {} + this.statisticHistory.get( + formatDateMinimal(getMidnightAlignedDate(date)), + ) || {} ); }; @@ -92,7 +94,7 @@ PlayerSchema.methods.setStatisticHistory = function ( this.statisticHistory = new Map(); } return this.statisticHistory.set( - formatDate(getMidnightAlignedDate(date)), + formatDateMinimal(getMidnightAlignedDate(date)), data, ); }; diff --git a/src/common/time-utils.ts b/src/common/time-utils.ts index 7cbde10..f46fd0a 100644 --- a/src/common/time-utils.ts +++ b/src/common/time-utils.ts @@ -29,13 +29,16 @@ export function timeAgo(input: Date | number) { } /** - * Formats the date + * Formats the date in the format "DD MMMM YYYY" * * @param date the date */ -export function formatDate(date: Date) { +export function formatDateMinimal(date: Date) { return date.toLocaleString("en-US", { timeZone: "Europe/London", + day: "numeric", + month: "short", + year: "numeric", }); }