feat: sortie rotation #1453

Merged
Sainan merged 5 commits from AMelonInsideLemon/SpaceNinjaServer:sortie into main 2025-04-07 05:29:22 -07:00
Contributor

Closes #1179

Closes #1179
AMelonInsideLemon added 1 commit 2025-04-03 16:50:17 -07:00
feat: sortie rotation
All checks were successful
Build / build (22) (pull_request) Successful in 36s
Build / build (20) (pull_request) Successful in 1m11s
Build / build (18) (pull_request) Successful in 1m8s
1ad7b3373d
Closes #1179
Owner

This looks good, but it should be cycled based on London, Ontario local time not UTC

This looks good, but it should be cycled based on London, Ontario local time not UTC
AMelonInsideLemon added 1 commit 2025-04-03 18:22:14 -07:00
correct rotation timestamp
All checks were successful
Build / build (18) (pull_request) Successful in 42s
Build / build (22) (pull_request) Successful in 1m16s
Build / build (20) (pull_request) Successful in 1m11s
d123f6cc62
Owner

I don't think this is correct. The rotation changes at either 17 UTC or 16 UTC depending on if London, Ontario is currently observing DST or not. Also the expiry would need to be set accordingly, so a sortie can last either 23 hours or 25 hours when switching between timezones (as DST comes and goes).

I don't think this is correct. The rotation changes at either 17 UTC or 16 UTC depending on if London, Ontario is currently observing DST or not. Also the expiry would need to be set accordingly, so a sortie can last either 23 hours or 25 hours when switching between timezones (as DST comes and goes).
AMelonInsideLemon added 1 commit 2025-04-03 19:26:43 -07:00
Update worldStateController.ts
All checks were successful
Build / build (20) (pull_request) Successful in 40s
Build / build (22) (pull_request) Successful in 1m15s
Build / build (18) (pull_request) Successful in 1m5s
b834b51904
AMelonInsideLemon changed title from feat: sortie rotation to WIP: feat: sortie rotation 2025-04-03 19:57:38 -07:00
Owner

This should be the correct way to handle this:

const sortieRolloverToday = getSortieTime(day);
if (Date.now() < sortieRolloverToday) {
    // Early in the day, generate sortie for `day - 1`, expiring at `sortieRolloverToday`.
} else {
    // Late in the day, generate sortie for `day`, expiring at `getSortieTime(day + 1)`.
}

Using the following utility:

const getSortieTime = (day: number): number => {
    const dayStart = EPOCH + day * 86400000;
    const date = new Date(dayStart);
    date.setUTCHours(12);
    const isDst = new Intl.DateTimeFormat("en-US", {
        timeZone: "America/Toronto",
        timeZoneName: "short"
    })
        .formatToParts(date)
        .find(part => part.type === "timeZoneName")!
        .value.includes("DT");
    return dayStart + (isDst ? 16 : 17) * 3600000;
};
This should be the correct way to handle this: ```ts const sortieRolloverToday = getSortieTime(day); if (Date.now() < sortieRolloverToday) { // Early in the day, generate sortie for `day - 1`, expiring at `sortieRolloverToday`. } else { // Late in the day, generate sortie for `day`, expiring at `getSortieTime(day + 1)`. } ``` Using the following utility: ```ts const getSortieTime = (day: number): number => { const dayStart = EPOCH + day * 86400000; const date = new Date(dayStart); date.setUTCHours(12); const isDst = new Intl.DateTimeFormat("en-US", { timeZone: "America/Toronto", timeZoneName: "short" }) .formatToParts(date) .find(part => part.type === "timeZoneName")! .value.includes("DT"); return dayStart + (isDst ? 16 : 17) * 3600000; }; ```
AMelonInsideLemon force-pushed sortie from b834b51904 to 15a1ac1ce1 2025-04-07 01:42:46 -07:00 Compare
AMelonInsideLemon added 1 commit 2025-04-07 01:42:59 -07:00
set sortie timestamps using getSortieTime
All checks were successful
Build / build (18) (pull_request) Successful in 42s
Build / build (20) (pull_request) Successful in 1m16s
Build / build (22) (pull_request) Successful in 1m11s
2c27cd1b56
Co-Authored-By: Sainan <63328889+Sainan@users.noreply.github.com>
AMelonInsideLemon changed title from WIP: feat: sortie rotation to feat: sortie rotation 2025-04-07 01:44:05 -07:00
AMelonInsideLemon added 1 commit 2025-04-07 01:45:22 -07:00
Update worldStateController.ts
All checks were successful
Build / build (18) (pull_request) Successful in 40s
Build / build (20) (pull_request) Successful in 1m9s
Build / build (22) (pull_request) Successful in 39s
fe5a8e40b1
Sainan approved these changes 2025-04-07 05:27:15 -07:00
Sainan merged commit 919f12b8f9 into main 2025-04-07 05:29:22 -07:00
Sainan deleted branch sortie 2025-04-07 05:29:22 -07:00
Sign in to join this conversation.
No description provided.