@@ -2,6 +2,9 @@ package com.yapp.ndgl.feature.travel.model
22
33import com.yapp.ndgl.core.util.formatDecimal
44import com.yapp.ndgl.data.travel.model.PlaceDetailResponse
5+ import java.time.DayOfWeek
6+ import java.time.LocalDate
7+ import java.time.format.DateTimeFormatter
58import kotlin.time.Duration
69import kotlin.time.Duration.Companion.hours
710
@@ -59,3 +62,25 @@ fun PlaceDetailResponse.toPlaceInfo(): PlaceInfo {
5962 websiteUrl = place.websiteUri,
6063 )
6164}
65+ fun List<String>?.toOpeningHours (startDate : String , day : Int ): String? {
66+ if (this .isNullOrEmpty() || startDate.isBlank()) return null
67+
68+ val targetDayOfWeek = runCatching {
69+ val travelStartDate = LocalDate .parse(startDate, DateTimeFormatter .ISO_LOCAL_DATE )
70+ val targetDate = travelStartDate.plusDays((day - 1 ).toLong())
71+ targetDate.dayOfWeek
72+ }.getOrNull() ? : return null
73+
74+ val dayOfWeekName = when (targetDayOfWeek) {
75+ DayOfWeek .MONDAY -> " 월요일"
76+ DayOfWeek .TUESDAY -> " 화요일"
77+ DayOfWeek .WEDNESDAY -> " 수요일"
78+ DayOfWeek .THURSDAY -> " 목요일"
79+ DayOfWeek .FRIDAY -> " 금요일"
80+ DayOfWeek .SATURDAY -> " 토요일"
81+ DayOfWeek .SUNDAY -> " 일요일"
82+ }
83+
84+ val openingHour = this .find { it.startsWith(dayOfWeekName) }
85+ return openingHour?.substringAfter(" :" )?.trim()
86+ }
0 commit comments