surely now
All checks were successful
Deploy / deploy (push) Successful in 2m36s

This commit is contained in:
Lee 2024-09-28 06:37:10 +01:00
parent 0410f6b324
commit 963faa23f3
3 changed files with 12 additions and 7 deletions

@ -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,

@ -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,
);
};

@ -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",
});
}