-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- CalendarPeriod 레코드 생성 - 기간계산 로직 분리
- Loading branch information
Showing
2 changed files
with
27 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
backend/src/main/java/team/teamby/teambyteam/schedule/domain/CalendarPeriod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package team.teamby.teambyteam.schedule.domain; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
|
||
public record CalendarPeriod( | ||
LocalDateTime startDateTime, | ||
LocalDateTime endDatetime | ||
) { | ||
private static final int FIRST_DAY_OF_MONTH = 1; | ||
private static final LocalTime START_TIME_OF_DAY = LocalTime.of(0, 0, 0); | ||
public static final int NEXT_MONTH_OFFSET = 1; | ||
|
||
public static CalendarPeriod of(final int year, final int month) { | ||
final LocalDate startDate = LocalDate.of(year, month, FIRST_DAY_OF_MONTH); | ||
final LocalDate endDate = startDate.plusMonths(NEXT_MONTH_OFFSET).withDayOfMonth(FIRST_DAY_OF_MONTH); | ||
|
||
return new CalendarPeriod(LocalDateTime.of(startDate, START_TIME_OF_DAY), LocalDateTime.of(endDate, START_TIME_OF_DAY)); | ||
} | ||
|
||
} |