Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2073eb9

Browse files
use proper timezone to download the input
Took 10 minutes
1 parent 2c0bdaf commit 2073eb9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎src/main/java/aminetti/adventofcode2024/DaySetup.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.time.Duration;
1919
import java.time.LocalDate;
2020
import java.time.Month;
21+
import java.time.ZoneId;
2122
import java.util.regex.Matcher;
2223
import java.util.regex.Pattern;
2324

@@ -41,7 +42,7 @@ public static void main(String... args) throws IOException, InterruptedException
4142

4243
}
4344

44-
static void cleanCodeAndTestAndInputForDay(int year, int day) throws IOException, InterruptedException {
45+
static void cleanCodeAndTestAndInputForDay(int year, int day) throws IOException {
4546
String basePackageName = String.format("adventofcode%d", year);
4647
String packageName = String.format("day%02d", day);
4748

@@ -106,7 +107,7 @@ static void prepareCookie() throws IOException {
106107
}
107108

108109

109-
static void prepareTestsForDay(int year, int day) throws IOException, InterruptedException {
110+
static void prepareTestsForDay(int year, int day) throws IOException {
110111
String basePackageName = String.format("adventofcode%d", year);
111112
String packageName = String.format("day%02d", day);
112113
String testClassName = String.format("Day%02dTest", day);
@@ -135,7 +136,7 @@ static void prepareTestsForDay(int year, int day) throws IOException, Interrupte
135136

136137
}
137138

138-
static void prepareCodeForDay(int year, int day) throws IOException, InterruptedException {
139+
static void prepareCodeForDay(int year, int day) throws IOException {
139140
String basePackageName = String.format("adventofcode%d", year);
140141
String packageName = String.format("day%02d", day);
141142
String className = String.format("Day%02d", day);
@@ -182,10 +183,13 @@ static void downloadDayInput(int year, int day) throws IOException, InterruptedE
182183
}
183184

184185
static int getCurrentDay() {
185-
LocalDate now = LocalDate.now();
186+
LocalDate now = LocalDate.now(ZoneId.of("America/New_York"));
186187
if (now.getMonth() != Month.DECEMBER) {
187188
throw new IllegalArgumentException("It is still not December.");
188189
}
190+
if (now.getDayOfMonth() > 25) {
191+
throw new IllegalArgumentException("No more exercises after the 25th.");
192+
}
189193

190194
return now.getDayOfMonth();
191195
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /