2 Commits

Author SHA1 Message Date
32e8468126 now?!?!?
All checks were successful
Deploy / deploy (push) Successful in 2m50s
2024-09-28 06:21:25 +01:00
1c9c76f721 now? 2024-09-28 06:20:42 +01:00
2 changed files with 5 additions and 9 deletions

View File

@ -70,7 +70,7 @@ PlayerSchema.methods.getLastTracked = function (): Date {
PlayerSchema.methods.getHistory = function (date: Date): PlayerHistory { PlayerSchema.methods.getHistory = function (date: Date): PlayerHistory {
return ( return (
this.statisticHistory.get(getMidnightAlignedDate(date).toString()) || {} this.statisticHistory.get(getMidnightAlignedDate(date).toUTCString()) || {}
); );
}; };
@ -91,7 +91,7 @@ PlayerSchema.methods.setStatisticHistory = function (
if (!this.statisticHistory) { if (!this.statisticHistory) {
this.statisticHistory = new Map(); this.statisticHistory = new Map();
} }
const alignedDate = getMidnightAlignedDate(date).toString(); const alignedDate = getMidnightAlignedDate(date).toUTCString();
return this.statisticHistory.set(alignedDate, data); return this.statisticHistory.set(alignedDate, data);
}; };
@ -111,7 +111,7 @@ PlayerSchema.methods.sortStatisticHistory = function (): Map<
Date.parse(b[0]) - Date.parse(a[0]), Date.parse(b[0]) - Date.parse(a[0]),
) )
// Convert the date strings back to Date objects for the resulting Map // Convert the date strings back to Date objects for the resulting Map
.map(([date, history]) => [new Date(date).toString(), history]), .map(([date, history]) => [new Date(date).toUTCString(), history]),
); );
return this.statisticHistory; return this.statisticHistory;
}; };

View File

@ -34,13 +34,9 @@ export function timeAgo(input: Date | number) {
* @param date the date * @param date the date
*/ */
export function getMidnightAlignedDate(date: Date) { export function getMidnightAlignedDate(date: Date) {
const midnightDate = new Date( return new Date(
date.getFullYear(), Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()),
date.getMonth(),
date.getDate(),
); );
midnightDate.setUTCHours(0, 0, 0, 0);
return midnightDate;
} }
/** /**