correct rotation timestamp

This commit is contained in:
AMelonInsideLemon 2025-04-04 03:22:32 +02:00
parent 6df67464ae
commit 18f6db7cdd
2 changed files with 28 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import { config } from "@/src/services/configService";
import { CRng } from "@/src/services/rngService"; import { CRng } from "@/src/services/rngService";
import { ExportNightwave, ExportRegions } from "warframe-public-export-plus"; import { ExportNightwave, ExportRegions } from "warframe-public-export-plus";
import { import {
getTorontoTimeAtHour,
missionTags, missionTags,
sortieBosses, sortieBosses,
sortieBossNode, sortieBossNode,
@ -165,7 +166,7 @@ export const worldStateController: RequestHandler = (req, res) => {
// Sortie cycling every day // Sortie cycling every day
{ {
const dayStart = EPOCH + day * 86400000; const dayStart = getTorontoTimeAtHour(EPOCH + day * 86400000, 12);
const dayEnd = dayStart + 86400000; const dayEnd = dayStart + 86400000;
const rng = new CRng(day); const rng = new CRng(day);

View File

@ -112,3 +112,29 @@ export const sortieBossNode: Record<string, string> = {
SORTIE_BOSS_LEPHANTIS: "SolNode712", SORTIE_BOSS_LEPHANTIS: "SolNode712",
SORTIE_BOSS_INFALAD: "SolNode705" SORTIE_BOSS_INFALAD: "SolNode705"
}; };
// ChatGPT generated that. And seems it works fine
export const getTorontoTimeAtHour = (date: number, hour: number): number => {
const formatter = new Intl.DateTimeFormat("en-US", {
timeZone: "America/Toronto",
year: "numeric",
month: "2-digit",
day: "2-digit"
});
const parts = formatter.formatToParts(date).reduce<Record<string, string>>((acc, { type, value }) => {
if (["year", "month", "day"].includes(type)) {
acc[type] = value;
}
return acc;
}, {});
const assumedLocalDate = new Date(
`${parts.year}-${parts.month}-${parts.day}T${hour.toString().padStart(2, "0")}:00:00`
);
const localDate = new Date(assumedLocalDate.toLocaleString("en-US", { timeZone: "America/Toronto" }));
const offsetMs = assumedLocalDate.getTime() - localDate.getTime();
return assumedLocalDate.getTime() + offsetMs;
};