From ad8f08a577d8c3312344335c9cbe6cfa2475810d Mon Sep 17 00:00:00 2001 From: atsunatsu Date: Sun, 2 Aug 2026 20:26:01 +0800 Subject: [PATCH] fix: revert DateFormat.FULL to SimpleDateFormat with locale DateFormat.FULL may cause inconsistent date labels between computeSunTimes and groupPasses, leading to missing or wrong sunrise/sunset times. Revert to the original pattern "EEE, dd MMM yyyy" but with Locale.getDefault() so day names follow the system language. --- .../com/rtbishop/look4sat/feature/passes/PassesViewModel.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 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 4110e274..9227ef04 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,7 +37,6 @@ 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 @@ -157,7 +156,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 = DateFormat.getDateInstance(DateFormat.FULL, Locale.getDefault()).also { it.timeZone = tz } + val sdfDate = SimpleDateFormat("EEE, dd MMM yyyy", 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 @@ -181,7 +180,7 @@ class PassesViewModel( private fun groupPasses(passes: List, isUtc: Boolean): Map> { val tz = if (isUtc) TimeZone.getTimeZone("UTC") else TimeZone.getDefault() - val sdfDate = DateFormat.getDateInstance(DateFormat.FULL, Locale.getDefault()).also { it.timeZone = tz } + val sdfDate = SimpleDateFormat("EEE, dd MMM yyyy", Locale.getDefault()).also { it.timeZone = tz } val ordered = LinkedHashMap>() val deepSpace = passes.filter { it.isDeepSpace } if (deepSpace.isNotEmpty()) ordered["DeepSpace (period >225min)"] = deepSpace