Handle 25 hour days correctly (#10635)
Some checks are pending
Node.js CI / build (16.x) (push) Waiting to run

This commit is contained in:
urkerab 2024-11-03 03:45:34 +00:00 committed by GitHub
parent 6ce2c653b4
commit 9f29c90db2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 7 deletions

View File

@ -52,7 +52,7 @@ function nextDaily() {
const midnight = new Date();
midnight.setHours(24, 0, 0, 0);
let timeout = setTimeout(nextDaily, midnight.valueOf() - Date.now());
let timeout = setTimeout(nextDaily, midnight.getTime() - Date.now());
export async function renderSpotlight(roomid: RoomID, key: string, index: number) {
let imgHTML = '';

View File

@ -228,8 +228,7 @@ export function rollTimer() {
void updateBadgeholders();
const time = Date.now();
const next = new Date();
next.setHours(next.getHours() + 1);
next.setMinutes(0, 0, 0);
next.setHours(next.getHours() + 1, 0, 0, 0);
updateTimeout = setTimeout(() => rollTimer(), next.getTime() - time);
const discussionRoom = Rooms.search('seasondiscussion');

View File

@ -140,8 +140,8 @@ export const PrivateMessages = new class {
if (!PM.isParentProcess) return null!;
const time = Date.now();
// even though we expire once a week atm, we check once a day
const nextMidnight = new Date(time + 24 * 60 * 60 * 1000);
nextMidnight.setHours(0, 0, 1);
const nextMidnight = new Date();
nextMidnight.setHours(24, 0, 0, 0);
if (this.clearInterval) clearTimeout(this.clearInterval);
this.clearInterval = setTimeout(() => {
void this.clearOffline();

View File

@ -327,8 +327,8 @@ export class Roomlog {
log.setupRoomlogStream();
}
const time = Date.now();
const nextMidnight = new Date(time + 24 * 60 * 60 * 1000);
nextMidnight.setHours(0, 0, 1);
const nextMidnight = new Date();
nextMidnight.setHours(24, 0, 0, 0);
Roomlogs.rollLogTimer = setTimeout(() => Roomlog.rollLogs(), nextMidnight.getTime() - time);
}
truncate() {