Skip to content

Commit

Permalink
Clean up getNextReset method
Browse files Browse the repository at this point in the history
  • Loading branch information
Almighty-Satan committed Oct 1, 2024
1 parent 6ca0e78 commit 3c7d34e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/de/cuuky/varo/threads/daily/DailyTimer.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package de.cuuky.varo.threads.daily;

import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Date;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -44,12 +42,11 @@ private static long getDateDiff(Date date1, Date date2, TimeUnit timeUnit) {
}

private static long getNextReset(long offset) {
ZoneOffset zone = OffsetDateTime.now().getOffset();
LocalDateTime reset = LocalDateTime.now().withHour(ConfigSetting.RESET_SESSION_HOUR.getValueAsInt()).withMinute(0).withSecond(0).withNano(0);
long resetTime = reset.toInstant(zone).toEpochMilli();
OffsetDateTime reset = OffsetDateTime.now().withHour(ConfigSetting.RESET_SESSION_HOUR.getValueAsInt()).withMinute(0).withSecond(0).withNano(0);
long resetTime = reset.toInstant().toEpochMilli();
long time = System.currentTimeMillis();
if (resetTime <= (time + offset))
resetTime = reset.plusDays(1).toInstant(zone).toEpochMilli();
resetTime = reset.plusDays(1).toInstant().toEpochMilli();
return (resetTime - time) / 1000L;
}

Expand Down

0 comments on commit 3c7d34e

Please sign in to comment.