making sure to use utc

This commit is contained in:
Jack 2020-07-05 17:56:16 +01:00
parent 0f286d67d4
commit 340ed1e458
2 changed files with 7 additions and 6 deletions

View file

@ -960,7 +960,7 @@ exports.getLeaderboard = functions.https.onCall((request, response) => {
}
// console.log(lbdata);
if (request.type === "daily") {
let resetTime = new Date();
let resetTime = new Date(Date.now());
resetTime.setHours(0, 0, 0, 0);
resetTime.setDate(resetTime.getUTCDate() + 1);
resetTime = resetTime.valueOf();

View file

@ -97,19 +97,20 @@ function updateLeaderboards() {
//daily
let diffAsDate = new Date(dailyData.resetTime - Date.now());
let diffHours = diffAsDate.getHours();
let diffMinutes = diffAsDate.getMinutes();
let diffSeconds = diffAsDate.getSeconds();
let diffHours = diffAsDate.getUTCHours();
let diffMinutes = diffAsDate.getUTCMinutes();
let diffSeconds = diffAsDate.getUTCSeconds();
let resetString = "";
if (diffHours > 0) {
resetString = `resets in ${diffHours} ${
diffHours == 1 ? "hour" : "hours"
}`;
} ${diffMinutes} ${diffMinutes == 1 ? "minute" : "minutes"}
`;
} else if (diffMinutes > 0) {
resetString = `resets in ${diffMinutes} ${
diffMinutes == 1 ? "minute" : "minutes"
}`;
} ${diffSeconds == 1 ? "second" : "seconds"}`;
} else if (diffSeconds > 0) {
resetString = `resets in ${diffSeconds} ${
diffSeconds == 1 ? "second" : "seconds"