@@ -5,6 +5,7 @@ import com.yapp.core.ui.R
55import java.time.LocalDate
66import java.time.LocalTime
77import java.time.format.DateTimeFormatter
8+ import java.util.Locale
89
910fun formatToDay (context : Context , date : String ): String {
1011 return try {
@@ -24,25 +25,15 @@ fun formatTimeRange(context: Context, startTime: String?, endTime: String?): Str
2425fun formatToKoreanTime (context : Context , time : String ): String {
2526 return try {
2627 val parsedTime = LocalTime .parse(time)
27- val hour = parsedTime.hour
28- val minute = parsedTime.minute
29-
30- val isAm = hour < 12
31- val hour12 = if (hour == 0 || hour == 12 ) 12 else hour % 12
32-
33- when (minute) {
34- 0 -> context.getString(
35- if (isAm) R .string.time_format_hour else R .string.time_format_hour_pm,
36- hour12
37- )
38- 30 -> context.getString(
39- if (isAm) R .string.time_format_half_hour else R .string.time_format_half_hour_pm,
40- hour12
41- )
42- else -> context.getString(
43- if (isAm) R .string.time_format_hour_minute else R .string.time_format_hour_minute_pm,
44- hour12, minute
45- )
28+
29+ val pattern = context.getString(R .string.time_format_base)
30+ val formatter = DateTimeFormatter .ofPattern(pattern, Locale .KOREAN )
31+ val base = parsedTime.format(formatter)
32+
33+ when (parsedTime.minute) {
34+ 0 -> base
35+ 30 -> context.getString(R .string.time_format_half_hour_with_base, base)
36+ else -> context.getString(R .string.time_format_hour_minute_with_base, base, parsedTime.minute)
4637 }
4738 } catch (e: Exception ) {
4839 time
0 commit comments