|
65 | 65 | */ |
66 | 66 | public final class CindyBootstrap { |
67 | 67 | private static final int MAXIMUM_MASTODON_MESSAGE_LENGTH = 500; |
68 | | - private static final DateTimeFormatter GERMAN_TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("d. LLLL yyyy HH:mm", GERMANY); |
69 | | - private static final DateTimeFormatter GERMAN_DATE_FORMATTER = DateTimeFormatter.ofPattern("d. LLLL yyyy", GERMANY); |
70 | 68 | private static final Logger LOGGER = Logger.getLogger(CindyBootstrap.class.getName()); |
71 | | - private static final ZoneId EUROPE_BERLIN = ZoneId.of("Europe/Berlin"); |
72 | 69 |
|
73 | 70 | public static void main(final String[] args) throws InterruptedException, ExecutionException { |
| 71 | + final var targetZone = Optional.ofNullable(System.getenv("CINDY_TARGET_ZONE")).map(ZoneId::of).orElseGet(ZoneId::systemDefault); |
| 72 | + final var TARGET_TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("d. LLLL yyyy HH:mm", GERMANY).withZone(targetZone); |
| 73 | + final var TARGET_DATE_FORMATTER = DateTimeFormatter.ofPattern("d. LLLL yyyy", GERMANY).withZone(targetZone); |
74 | 74 | final var mastodonHost = System.getenv("CINDY_MASTODON_HOST"); |
75 | 75 | final var mastodonAccessToken = System.getenv("CINDY_MASTODON_ACCESS_TOKEN"); |
76 | 76 | final var lastRunFile = Path.of(System.getenv().getOrDefault("CINDY_DATA", "."), "lastRun"); |
@@ -177,8 +177,8 @@ public void run() { |
177 | 177 | switch (event.begin()) { |
178 | 178 | case ZonedDateTime zonedDatetime when zonedDatetime.toInstant().isAfter(startOfPullingCalendar) -> true; |
179 | 179 | case OffsetDateTime offsetDateTime when offsetDateTime.toInstant().isAfter(startOfPullingCalendar) -> true; |
180 | | - case LocalDateTime localDateTime when localDateTime.atZone(EUROPE_BERLIN).toInstant().isAfter(startOfPullingCalendar) -> true; |
181 | | - case LocalDate localDate when localDate.atStartOfDay().atZone(EUROPE_BERLIN).toInstant().isAfter(startOfPullingCalendar) -> true; |
| 180 | + case LocalDateTime localDateTime when localDateTime.atZone(targetZone).toInstant().isAfter(startOfPullingCalendar) -> true; |
| 181 | + case LocalDate localDate when localDate.atStartOfDay().atZone(targetZone).toInstant().isAfter(startOfPullingCalendar) -> true; |
182 | 182 | case ZonedDateTime zonedDatetime -> { |
183 | 183 | LOGGER.finer(() -> "Ignoring event because it begins in the past: '%s'.".formatted(event.uid())); |
184 | 184 | yield false; |
@@ -223,10 +223,10 @@ public void run() { |
223 | 223 | case null: |
224 | 224 | break; |
225 | 225 | case LocalDate ld: |
226 | | - message.append("\n📅 ").append(GERMAN_DATE_FORMATTER.format(ld)); |
| 226 | + message.append("\n📅 ").append(TARGET_DATE_FORMATTER.format(ld)); |
227 | 227 | break; |
228 | 228 | default: |
229 | | - message.append("\n📅 ").append(GERMAN_TIMESTAMP_FORMATTER.format(event.begin())); |
| 229 | + message.append("\n📅 ").append(TARGET_TIMESTAMP_FORMATTER.format(event.begin())); |
230 | 230 | } |
231 | 231 | if (event.location() != null) |
232 | 232 | message.append("\n🏠️ ").append(event.location()); |
|
0 commit comments