Skip to content

Commit

Permalink
🔨 refactor: LocalDate 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
SONGS4RI committed Dec 30, 2023
1 parent 455c4d5 commit e9658dc
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.gg.server.global.config.ConstantConfig;
import com.gg.server.global.exception.ErrorCode;
import com.gg.server.global.exception.custom.InvalidParameterException;
import java.time.LocalDate;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -211,11 +212,9 @@ private void checkValidTournamentTime(LocalDateTime startTime, LocalDateTime end
SlotManagement slotManagement = slotManagementRepository.findCurrent(startTime)
.orElseThrow(SlotNotFoundException::new);
int interval = slotManagement.getGameInterval();
int startDays = startTime.getDayOfYear() + (startTime.getYear() - LocalDateTime.now().getYear()) * 365;
int curDays = LocalDateTime.now().getDayOfYear();

if (startTime.isAfter(endTime) || startTime.isEqual(endTime) ||
startDays - curDays < constantConfig.getAllowedMinimalStartDays() ||
LocalDate.now().plusDays(constantConfig.getAllowedMinimalStartDays()).isAfter(startTime.toLocalDate()) ||
startTime.plusHours(Tournament.MINIMUM_TOURNAMENT_DURATION).isAfter(endTime) ||
startTime.getMinute() % interval != 0 || endTime.getMinute() % interval != 0) {
throw new TournamentUpdateException(ErrorCode.TOURNAMENT_INVALID_TIME);
Expand Down

0 comments on commit e9658dc

Please sign in to comment.