Last active 1 month ago

gistfile1.txt Raw
1 resetWeek(): void {
2 // Fire the weekly reset on Monday 00:00 (WRank reset) (UTC+2 = Sunday 22:00)
3 const nowUtcNoon = new Date();
4 nowUtcNoon.setUTCHours(12, 0, 0, 0);
5
6 const newWeekKey = WRank.weekKey(nowUtcNoon);
7 const prevWeekKey = WRank.weekKey(new Date(nowUtcNoon.getTime() - 7 * 24 * 60 * 60 * 1000));
8 const prevWeek = _data[prevWeekKey];
9 const newWeek = ensureWeek(newWeekKey);
10
11 if (prevWeek) {
12 Bringer.update({ week: prevWeek });
13 for (const nation of [Nation.Capella, Nation.Procyon]) {
14 const bringer = prevWeek.bringer[nation];
15 if (bringer) newWeek.bringer[nation] = bringer;
16 }
17 }
18
19 WRank.save();
20 log.info(`Week reset to ${newWeekKey}. Bringer: ${JSON.stringify(newWeek.bringer)}`);
21 },