dspace-api: use minusDays and minusWeeks helpers

IntelliJ suggested we use minusDays and minusWeeks helpers.

(cherry picked from commit 125767af6e)
This commit is contained in:
Alan Orth
2025-07-04 17:03:14 +03:00
committed by github-actions[bot]
parent f442436580
commit 63a2a160f8

View File

@@ -44,14 +44,12 @@ public enum FrequencyType {
case "D": case "D":
// Frequency is anything updated yesterday. // Frequency is anything updated yesterday.
// startDate is beginning of day yesterday // startDate is beginning of day yesterday
Instant startOfYesterday = ZonedDateTime.now(ZoneOffset.UTC) Instant startOfYesterday = ZonedDateTime.now(ZoneOffset.UTC).minusDays(1)
.minus(1, ChronoUnit.DAYS)
.with(LocalTime.MIN) .with(LocalTime.MIN)
.toInstant(); .toInstant();
startDate = startOfYesterday.toString(); startDate = startOfYesterday.toString();
// endDate is end of day yesterday // endDate is end of day yesterday
Instant endOfYesterday = ZonedDateTime.now(ZoneOffset.UTC) Instant endOfYesterday = ZonedDateTime.now(ZoneOffset.UTC).minusDays(1)
.minus(1, ChronoUnit.DAYS)
.with(LocalTime.MAX) .with(LocalTime.MAX)
.toInstant(); .toInstant();
endDate = endOfYesterday.toString(); endDate = endOfYesterday.toString();
@@ -75,15 +73,13 @@ public enum FrequencyType {
case "W": case "W":
// Frequency is anything updated last week // Frequency is anything updated last week
// startDate is beginning of last week (Sunday, beginning of the day) // startDate is beginning of last week (Sunday, beginning of the day)
Instant startOfLastWeek = ZonedDateTime.now(ZoneOffset.UTC) Instant startOfLastWeek = ZonedDateTime.now(ZoneOffset.UTC).minusWeeks(1)
.minus(1, ChronoUnit.WEEKS)
.with(previousOrSame(DayOfWeek.SUNDAY)) .with(previousOrSame(DayOfWeek.SUNDAY))
.with(LocalTime.MIN) .with(LocalTime.MIN)
.toInstant(); .toInstant();
startDate = startOfLastWeek.toString(); startDate = startOfLastWeek.toString();
// End date is end of last week (Saturday, end of day) // End date is end of last week (Saturday, end of day)
Instant endOfLastWeek = ZonedDateTime.now(ZoneOffset.UTC) Instant endOfLastWeek = ZonedDateTime.now(ZoneOffset.UTC).minusWeeks(1)
.minus(1, ChronoUnit.WEEKS)
.with(nextOrSame(DayOfWeek.SATURDAY)) .with(nextOrSame(DayOfWeek.SATURDAY))
.with(LocalTime.MAX) .with(LocalTime.MAX)
.toInstant(); .toInstant();