다국어 설정 시 날짜 포맷이 섞이는 버그 수정
앱 내 설정 언어와 디바이스 언어가 다를 때 날짜 포맷에 여러 언어가 섞여서 표시되는 문제를 해결하기 위해 앱 설정 언어를 명시적으로 적용하도록 수정. 래핑된 컨텍스트를 사용하여 리소스를 가져오고 날짜 변환 시에도 해당 로케일을 전달하도록 개선.
This commit is contained in:
@@ -73,25 +73,25 @@ fun String.formatMoney(currencyCode: String, locale: Locale = Locale.getDefault(
|
||||
return nf.format(bd)
|
||||
}
|
||||
|
||||
fun String.parseUtcIsoLocalDateTime(): Map<String, String> {
|
||||
fun String.parseUtcIsoLocalDateTime(locale: Locale = Locale.getDefault()): Map<String, String> {
|
||||
// 1. 서버가 내려준 포맷: "yyyy-MM-dd'T'HH:mm:ss"
|
||||
val utcFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault())
|
||||
val utcFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", locale)
|
||||
utcFormat.timeZone = TimeZone.getTimeZone("UTC") // 서버가 UTC 기준으로 보낸 것
|
||||
|
||||
// 2. Date 객체 생성
|
||||
val date = utcFormat.parse(this)!!
|
||||
|
||||
// 3. 월 (1~12)
|
||||
val month = SimpleDateFormat("M", Locale.getDefault()).format(date)
|
||||
val month = SimpleDateFormat("M", locale).format(date)
|
||||
|
||||
// 4. 일 (1~31)
|
||||
val day = SimpleDateFormat("d", Locale.getDefault()).format(date)
|
||||
val day = SimpleDateFormat("d", locale).format(date)
|
||||
|
||||
// 5. 요일 (예: "Mon", "목")
|
||||
val dayOfWeek = SimpleDateFormat("E", Locale.getDefault()).format(date)
|
||||
val dayOfWeek = SimpleDateFormat("E", locale).format(date)
|
||||
|
||||
// 6. 시간 (예: "AM 05:00")
|
||||
val time = SimpleDateFormat("a hh:mm", Locale.getDefault()).format(date)
|
||||
val time = SimpleDateFormat("a hh:mm", locale).format(date)
|
||||
|
||||
return mapOf(
|
||||
"month" to month,
|
||||
|
||||
Reference in New Issue
Block a user