diff --git a/CHANGELOG.md b/CHANGELOG.md index 2122098..1fd0671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Fixed issue with puzzle unlock time being 2pm EST instead of midnight EST ([#238](https://github.com/beakerandjake/advent-of-code-runner/issues/238)) ## [1.6.0] - 2023-11-17 ### Changed diff --git a/src/validation/validatePuzzle.js b/src/validation/validatePuzzle.js index fea372a..3bfc281 100644 --- a/src/validation/validatePuzzle.js +++ b/src/validation/validatePuzzle.js @@ -10,7 +10,7 @@ export const puzzleIsInFuture = (year, day) => { if (year !== new Date().getFullYear()) { return year > new Date().getFullYear(); } - const puzzleUnlockTimeUTC = Date.UTC(year, 11, day, 19); + const puzzleUnlockTimeUTC = Date.UTC(year, 11, day, 5); return Date.now() < puzzleUnlockTimeUTC; }; diff --git a/tests/validation/validatePuzzle.test.js b/tests/validation/validatePuzzle.test.js index b5dccbe..648114c 100644 --- a/tests/validation/validatePuzzle.test.js +++ b/tests/validation/validatePuzzle.test.js @@ -55,24 +55,24 @@ describe('validatePuzzle', () => { expect(result).toBe(true); }); - // test literally every minute from midnight until unlock time. - [...Array(60 * 19).keys()].forEach((minutes) => { + // test literally every minute from UTC midnight until unlock time. + [...Array(60 * 5).keys()].forEach((minutes) => { const year = 2022; const day = 22; const utcMidnightMs = new Date(year, 11, day).setUTCHours(0, 0, 0, 0); const systemTime = new Date(utcMidnightMs + minutes * 60000); - test(`returns false - same day time is: ${systemTime.toISOString()}`, () => { + test(`returns true - same day time is: ${systemTime.toISOString()}`, () => { jest.setSystemTime(systemTime); expect(puzzleIsInFuture(year, day)).toBe(true); }); }); // test literally every minute from unlock time until midnight. - [...Array(60 * 5).keys()].forEach((minutes) => { + [...Array(60 * 7).keys()].forEach((minutes) => { const year = 2022; const day = 22; - const utcUnlockTimeMs = new Date(year, 11, day).setUTCHours(19, 0, 0, 0); + const utcUnlockTimeMs = new Date(year, 11, day).setUTCHours(5, 0, 0, 0); const systemTime = new Date(utcUnlockTimeMs + minutes * 60000); test(`returns false - same day time is: ${systemTime.toISOString()}`, () => {