fix: premature week rollover #771
@ -20,7 +20,7 @@ export const worldStateController: RequestHandler = (req, res) => {
|
||||
};
|
||||
|
||||
const day = Math.trunc(new Date().getTime() / 86400000);
|
||||
const week = Math.trunc((day + 4) / 7); // week begins on mondays
|
||||
const week = Math.trunc((day + 3) / 7); // week begins on mondays
|
||||
const weekStart = week * 604800000;
|
||||
|
||||
const weekEnd = weekStart + 604800000;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user
💡 Codebase verification
⚠️ Potential issue
Incorrect week calculation offset will misalign weekly rotations
The change from
+4
to+3
in the week calculation is incorrect. Since Unix epoch (Jan 1, 1970) was a Thursday, we need +4 days to align with the next Monday. Using +3 will cause weeks to start on Sundays instead, breaking the intended Monday-based weekly rotations for:Fix by reverting to the original offset:
🔗 Analysis chain
Revert the offset change to maintain Monday-based weeks.
The change from
+4
to+3
is incorrect and will cause weeks to start on Sundays instead of Mondays. Here's why:day
counts days since Unix epoch (Jan 1, 1970), which was a Thursday+4
, not+3
This change will cause all weekly cycles to shift by one day, affecting:
Apply this diff to fix the week calculation:
Let's verify the week calculation:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 44