From fa55b82a5a6581daedd37fcdc7f42465ea88e45e Mon Sep 17 00:00:00 2001 From: atsunatsu Date: Sun, 2 Aug 2026 19:34:43 +0800 Subject: [PATCH] fix(i18n): use locale-aware full date format for Chinese convention MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace SimpleDateFormat("EEE, dd MMM yyyy") with DateFormat.getDateInstance(DateFormat.FULL, locale) which automatically uses the correct format for each locale: - Chinese: "2026年8月1日 星期六" - English: "Saturday, August 1, 2026" - Other locales: their respective conventions --- .../com/rtbishop/look4sat/feature/passes/PassesViewModel.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/feature/passes/src/main/java/com/rtbishop/look4sat/feature/passes/PassesViewModel.kt b/feature/passes/src/main/java/com/rtbishop/look4sat/feature/passes/PassesViewModel.kt index 9227ef04..4110e274 100644 --- a/feature/passes/src/main/java/com/rtbishop/look4sat/feature/passes/PassesViewModel.kt +++ b/feature/passes/src/main/java/com/rtbishop/look4sat/feature/passes/PassesViewModel.kt @@ -37,6 +37,7 @@ import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.update import kotlinx.coroutines.isActive import kotlinx.coroutines.launch +import java.text.DateFormat import java.text.SimpleDateFormat import java.util.Date import java.util.Locale @@ -156,7 +157,7 @@ class PassesViewModel( private fun computeSunTimes(passes: List, isUtc: Boolean): Map> { val stationPos = settingsRepo.stationPosition.value val tz = if (isUtc) TimeZone.getTimeZone("UTC") else TimeZone.getDefault() - val sdfDate = SimpleDateFormat("EEE, dd MMM yyyy", Locale.getDefault()).also { it.timeZone = tz } + val sdfDate = DateFormat.getDateInstance(DateFormat.FULL, Locale.getDefault()).also { it.timeZone = tz } val sdfTime = SimpleDateFormat("HH:mm", Locale.getDefault()).also { it.timeZone = tz } val result = LinkedHashMap>() // DeepSpace group always shows today's sun times @@ -180,7 +181,7 @@ class PassesViewModel( private fun groupPasses(passes: List, isUtc: Boolean): Map> { val tz = if (isUtc) TimeZone.getTimeZone("UTC") else TimeZone.getDefault() - val sdfDate = SimpleDateFormat("EEE, dd MMM yyyy", Locale.getDefault()).also { it.timeZone = tz } + val sdfDate = DateFormat.getDateInstance(DateFormat.FULL, Locale.getDefault()).also { it.timeZone = tz } val ordered = LinkedHashMap>() val deepSpace = passes.filter { it.isDeepSpace } if (deepSpace.isNotEmpty()) ordered["DeepSpace (period >225min)"] = deepSpace