correct rotation timestamp
This commit is contained in:
parent
1ad7b3373d
commit
d123f6cc62
@ -11,6 +11,7 @@ import { config } from "@/src/services/configService";
|
||||
import { CRng } from "@/src/services/rngService";
|
||||
import { ExportNightwave, ExportRegions } from "warframe-public-export-plus";
|
||||
import {
|
||||
getTorontoTimeAtHour,
|
||||
missionTags,
|
||||
sortieBosses,
|
||||
sortieBossNode,
|
||||
@ -165,7 +166,7 @@ export const worldStateController: RequestHandler = (req, res) => {
|
||||
|
||||
// Sortie cycling every day
|
||||
{
|
||||
const dayStart = EPOCH + day * 86400000;
|
||||
const dayStart = getTorontoTimeAtHour(EPOCH + day * 86400000, 12);
|
||||
const dayEnd = dayStart + 86400000;
|
||||
|
||||
const rng = new CRng(day);
|
||||
|
@ -112,3 +112,29 @@ export const sortieBossNode: Record<string, string> = {
|
||||
SORTIE_BOSS_LEPHANTIS: "SolNode712",
|
||||
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;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user