Skip to content

Commit f877685

Browse files
Merge pull request #239 from beakerandjake/238-puzzle-unlock-time-is-wrong
238 puzzle unlock time is wrong
2 parents 387102c + ff35240 commit f877685

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
### Fixed
10+
- Fixed issue with puzzle unlock time being 2pm EST instead of midnight EST ([#238](https://github.com/beakerandjake/advent-of-code-runner/issues/238))
911

1012
## [1.6.0] - 2023-11-17
1113
### Changed

src/validation/validatePuzzle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const puzzleIsInFuture = (year, day) => {
1010
if (year !== new Date().getFullYear()) {
1111
return year > new Date().getFullYear();
1212
}
13-
const puzzleUnlockTimeUTC = Date.UTC(year, 11, day, 19);
13+
const puzzleUnlockTimeUTC = Date.UTC(year, 11, day, 5);
1414
return Date.now() < puzzleUnlockTimeUTC;
1515
};
1616

tests/validation/validatePuzzle.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,24 @@ describe('validatePuzzle', () => {
5555
expect(result).toBe(true);
5656
});
5757

58-
// test literally every minute from midnight until unlock time.
59-
[...Array(60 * 19).keys()].forEach((minutes) => {
58+
// test literally every minute from UTC midnight until unlock time.
59+
[...Array(60 * 5).keys()].forEach((minutes) => {
6060
const year = 2022;
6161
const day = 22;
6262
const utcMidnightMs = new Date(year, 11, day).setUTCHours(0, 0, 0, 0);
6363
const systemTime = new Date(utcMidnightMs + minutes * 60000);
6464

65-
test(`returns false - same day time is: ${systemTime.toISOString()}`, () => {
65+
test(`returns true - same day time is: ${systemTime.toISOString()}`, () => {
6666
jest.setSystemTime(systemTime);
6767
expect(puzzleIsInFuture(year, day)).toBe(true);
6868
});
6969
});
7070

7171
// test literally every minute from unlock time until midnight.
72-
[...Array(60 * 5).keys()].forEach((minutes) => {
72+
[...Array(60 * 7).keys()].forEach((minutes) => {
7373
const year = 2022;
7474
const day = 22;
75-
const utcUnlockTimeMs = new Date(year, 11, day).setUTCHours(19, 0, 0, 0);
75+
const utcUnlockTimeMs = new Date(year, 11, day).setUTCHours(5, 0, 0, 0);
7676
const systemTime = new Date(utcUnlockTimeMs + minutes * 60000);
7777

7878
test(`returns false - same day time is: ${systemTime.toISOString()}`, () => {

0 commit comments

Comments
 (0)