Skip to content

Commit 6637801

Browse files
committed
refactor: ReservedTimeInfo 매직넘버 상수화
1 parent 03ba8ba commit 6637801

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
package com.example.wini.domain.member.dto.common;
22

3+
import static com.example.wini.global.common.constant.StatusReserveTimeConstants.INDEFINITE_HOUR;
4+
import static com.example.wini.global.common.constant.StatusReserveTimeConstants.INDEFINITE_MINUTE;
5+
import static com.example.wini.global.common.constant.StatusReserveTimeConstants.INDEFINITE_SECONDS;
6+
import static com.example.wini.global.common.constant.StatusReserveTimeConstants.SECONDS_PER_HOUR;
7+
import static com.example.wini.global.common.constant.StatusReserveTimeConstants.SECONDS_PER_MINUTE;
8+
39
import jakarta.validation.constraints.Max;
410
import jakarta.validation.constraints.Min;
511
import jakarta.validation.constraints.NotNull;
6-
import java.time.Duration;
712

813
public record ReservedTimeInfo(
914
@NotNull @Min(value = -1) @Max(value = 12) Long hour, @NotNull @Min(value = -1) @Max(value = 59) Long minute) {
1015
public static ReservedTimeInfo of(long hour, long minute) {
1116
return new ReservedTimeInfo(hour, minute);
1217
}
1318

14-
public Duration toDuration() {
15-
if (this.hour == -1 && this.minute == -1) {
16-
return Duration.ofDays(365L * 100);
19+
public long toSeconds() {
20+
if (this.hour == INDEFINITE_HOUR && this.minute == INDEFINITE_MINUTE) {
21+
return INDEFINITE_SECONDS;
1722
}
18-
19-
return Duration.ofHours(this.hour).plusMinutes(this.minute);
23+
return this.hour * SECONDS_PER_HOUR + this.minute * SECONDS_PER_MINUTE;
2024
}
2125
}

0 commit comments

Comments
 (0)