Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/features/advent-of-code/advent-calendar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void describe('getPostContent', () => {
void it('renders a relative Discord timestamp for the event start during the countdown', () => {
assert.equal(
getPostContent({ year: 2026, day: 1, phase: 'countdown' }),
'Advent of Code 2026 starts <t:1796083200:R>'
'Advent of Code 2026 starts <t:1796101200:R>'
);
});

Expand Down
5 changes: 4 additions & 1 deletion src/features/advent-of-code/advent-calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { time } from 'discord.js';

export const POST_BEFORE_DAYS = 3;
export const FINAL_DAY = 12;
export const EVENT_TIME_ZONE = 'EST';

export type AdventPostPhase = 'countdown' | 'open';

Expand All @@ -17,7 +18,9 @@ const getEventStartDate = (year: number): Temporal.PlainDate =>
Temporal.PlainDate.from({ year, month: 12, day: 1 });

const getEventStartInstant = (year: number): Temporal.Instant =>
getEventStartDate(year).toZonedDateTime({ timeZone: 'UTC' }).toInstant();
getEventStartDate(year)
.toZonedDateTime({ timeZone: EVENT_TIME_ZONE })
.toInstant();

export const getAdventPostStep = (
today: Temporal.PlainDate
Expand Down
9 changes: 5 additions & 4 deletions src/features/advent-of-code/advent-scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SERVER_CHANNELS } from '@/constants/channels.js';
import { prisma } from '@/db/prisma.js';
import { createLogger } from '@/util/logger.js';
import {
EVENT_TIME_ZONE,
type AdventPostStep,
getAdventPostAction,
getAdventPostStep,
Expand Down Expand Up @@ -57,7 +58,7 @@ const revealFirstDay = async (
};

const runAdventPostCheck = async (): Promise<void> => {
const step = getAdventPostStep(Temporal.Now.plainDateISO('UTC'));
const step = getAdventPostStep(Temporal.Now.plainDateISO(EVENT_TIME_ZONE));

if (step === null) {
return;
Expand Down Expand Up @@ -86,18 +87,18 @@ const runScheduledAdventPostCheck = (): void => {

/**
* Posts a countdown to the event start, edits it into the day 1 link when the
* event opens, and posts each following day at midnight UTC.
* event opens, and posts each following day at midnight EST.
*/
export function initializeAdventScheduler(): void {
logger.info('🎄 Initializing Advent of Code scheduler...');

runScheduledAdventPostCheck();

cron.schedule('0 0 * * *', runScheduledAdventPostCheck, {
timezone: 'UTC',
timezone: EVENT_TIME_ZONE,
});

logger.info(
'✅ Advent of Code scheduler initialized (runs daily at midnight UTC)'
'✅ Advent of Code scheduler initialized (runs daily at midnight EST)'
);
}
Loading