diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/calendar/TimePicker.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/calendar/TimePicker.kt index 2307f99d..b56a6278 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/calendar/TimePicker.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/common/view/calendar/TimePicker.kt @@ -46,10 +46,17 @@ fun TimePicker( color = Gray700, fontWeight = FontWeight.SemiBold ) - - var hourValue by remember { mutableIntStateOf(if(localTime.hour==0) 12 else localTime.hour) } + var timeType by remember { + mutableStateOf(if (localTime.hour >= 12) TimePickerType.PM else TimePickerType.AM) + } + var hourValue by remember { + mutableIntStateOf( + if (localTime.hour > 12) localTime.hour - 12 + else if (localTime.hour == 0) 12 + else localTime.hour + ) + } var minuteValue by remember { mutableIntStateOf(localTime.minute) } - var timeType by remember { mutableStateOf(TimePickerType.AM) } BottomSheetScreen( onDismissRequest = onDismissRequest, @@ -86,12 +93,13 @@ fun TimePicker( modifier = Modifier .align(Alignment.CenterEnd) .clickable { + val transHour = when (timeType) { + TimePickerType.AM -> if (hourValue == 12) -12 else 0 + TimePickerType.PM -> if (hourValue == 12) 0 else 12 + } onConfirm( LocalTime( - hour = hourValue + when (timeType) { - TimePickerType.AM -> if (hourValue==12) -12 else 0 - TimePickerType.PM -> if (hourValue==12) 0 else 12 - }, + hour = hourValue + transHour, minute = minuteValue ) ) @@ -105,7 +113,7 @@ fun TimePicker( ) { NumberPicker( value = hourValue, - range = 1.. 12, + range = 1..12, dividersColor = Primary3, textStyle = timeTextStyle, onValueChange = { @@ -115,7 +123,7 @@ fun TimePicker( Spacer(modifier = Modifier.width(20.dp)) NumberPicker( value = minuteValue, - range = 0..if (hourValue == 12 && timeType == TimePickerType.PM) 0 else 59, + range = 0..59, dividersColor = Primary3, textStyle = timeTextStyle, onValueChange = { diff --git a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/schedule/add/ScheduleAddScreen.kt b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/schedule/add/ScheduleAddScreen.kt index 638e6453..c4254ce9 100644 --- a/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/schedule/add/ScheduleAddScreen.kt +++ b/presentation/src/main/kotlin/ac/dnd/bookkeeping/android/presentation/ui/main/home/schedule/add/ScheduleAddScreen.kt @@ -87,6 +87,7 @@ import kotlinx.datetime.TimeZone import kotlinx.datetime.minus import kotlinx.datetime.number import kotlinx.datetime.todayIn +import timber.log.Timber @Composable fun ScheduleAddScreen( @@ -248,7 +249,7 @@ fun ScheduleAddScreen( val fixedHour = if (it.hour == 0) 24 else it.hour val timeHour = (fixedHour - 1) % 12 + 1 val timeMinute = it.minute - val timeAmPm = if (fixedHour < 12) "오전" else "오후" + val timeAmPm = if (fixedHour < 12 || fixedHour == 24) "오전" else "오후" runCatching { String.format(format, timeAmPm, timeHour, timeMinute) }.onFailure { exception ->