File tree Expand file tree Collapse file tree
domain/src/main/java/com/threegap/bitnagil/domain/routine/model
presentation/src/main/java/com/threegap/bitnagil/presentation Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com.threegap.bitnagil.domain.routine.model
22
3- import java.time.LocalTime
4- import java.time.format.DateTimeFormatter
5- import java.util.Locale
6-
73data class Routine (
84 val routineId : String ,
95 val routineName : String ,
@@ -14,19 +10,4 @@ data class Routine(
1410 val subRoutineNames : List <String >,
1511 val subRoutineCompleteYn : List <Boolean >,
1612 val recommendedRoutineType : RecommendedRoutineType ? ,
17- ) {
18- private val koreanLocale = Locale .KOREAN
19- private val executionTimeFormatter12 = DateTimeFormatter .ofPattern(" a h:mm" , koreanLocale)
20-
21- val formattedExecutionTime: String =
22- try {
23- val time = LocalTime .parse(executionTime)
24- if (time == LocalTime .MIDNIGHT ) {
25- " 하루종일"
26- } else {
27- time.format(executionTimeFormatter12)
28- }
29- } catch (e: Exception ) {
30- " 시간 미정"
31- }
32- }
13+ )
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import androidx.compose.ui.unit.dp
1212import com.threegap.bitnagil.designsystem.BitnagilTheme
1313import com.threegap.bitnagil.presentation.home.component.block.RoutineItem
1414import com.threegap.bitnagil.presentation.home.model.RoutineUiModel
15- import com.threegap.bitnagil.presentation.home.util.formatExecutionTime
15+ import com.threegap.bitnagil.presentation.home.util.formatExecutionTime24Hour
1616
1717@Composable
1818fun RoutineSection (
@@ -26,7 +26,7 @@ fun RoutineSection(
2626 horizontalArrangement = Arrangement .spacedBy(8 .dp),
2727 ) {
2828 Text (
29- text = routine.executionTime.formatExecutionTime (),
29+ text = routine.executionTime.formatExecutionTime24Hour (),
3030 style = BitnagilTheme .typography.body2Medium,
3131 color = BitnagilTheme .colors.coolGray10,
3232 modifier = Modifier .defaultMinSize(minWidth = 42 .dp),
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import java.util.Locale
99
1010private val koreanLocale = Locale .KOREAN
1111private val monthYearFormatter = DateTimeFormatter .ofPattern(" yyyy년 M월" , koreanLocale)
12+ private val executionTimeFormatter12 = DateTimeFormatter .ofPattern(" a h:mm" , koreanLocale)
1213private val executionTimeFormatter24 = DateTimeFormatter .ofPattern(" HH:mm" , koreanLocale)
1314
1415fun LocalDate.getCurrentWeekDays (): List <LocalDate > =
@@ -23,7 +24,7 @@ fun LocalDate.formatDayOfWeekShort(): String =
2324fun LocalDate.formatDayOfMonth (): String =
2425 this .dayOfMonth.toString()
2526
26- fun String.formatExecutionTime (): String =
27+ fun String.formatExecutionTime24Hour (): String =
2728 try {
2829 val time = LocalTime .parse(this )
2930 if (time == LocalTime .MIDNIGHT ) {
@@ -34,3 +35,15 @@ fun String.formatExecutionTime(): String =
3435 } catch (e: Exception ) {
3536 " 시간 미정"
3637 }
38+
39+ fun String.formatExecutionTime12Hour (): String =
40+ try {
41+ val time = LocalTime .parse(this )
42+ if (time == LocalTime .MIDNIGHT ) {
43+ " 하루종일"
44+ } else {
45+ time.format(executionTimeFormatter12)
46+ }
47+ } catch (e: Exception ) {
48+ " 시간 미정"
49+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import com.threegap.bitnagil.designsystem.R
88import com.threegap.bitnagil.domain.routine.model.DayOfWeek
99import com.threegap.bitnagil.domain.routine.model.RecommendedRoutineType
1010import com.threegap.bitnagil.domain.routine.model.Routine
11+ import com.threegap.bitnagil.presentation.home.util.formatExecutionTime12Hour
1112import kotlinx.parcelize.Parcelize
1213
1314@Parcelize
@@ -26,7 +27,7 @@ fun Routine.toUiModel(): RoutineUiModel =
2627 routineId = this .routineId,
2728 routineName = this .routineName,
2829 repeatDay = this .repeatDay,
29- executionTime = this .formattedExecutionTime ,
30+ executionTime = this .executionTime.formatExecutionTime12Hour() ,
3031 routineDate = this .routineDate,
3132 subRoutineNames = this .subRoutineNames,
3233 recommendedRoutineType = this .recommendedRoutineType,
You can’t perform that action at this time.
0 commit comments