diff --git a/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/SatelliteRepo.kt b/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/SatelliteRepo.kt index bdbea85b..b9a27927 100644 --- a/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/SatelliteRepo.kt +++ b/core/data/src/main/java/com/rtbishop/look4sat/core/data/repository/SatelliteRepo.kt @@ -175,7 +175,16 @@ class SatelliteRepo( aosEndMinute: Int, invertAosTimeWindow: Boolean ): Boolean { - val offsetMillis = TimeZone.getDefault().getOffset(aosTime).toLong() + // Follow the UTC display toggle: with UTC enabled the window is interpreted + // in UTC, otherwise in the device's local timezone. Otherwise the pass list + // shows UTC times while the filter silently uses local time — the two + // disagree by the timezone offset (e.g. 8h for China). + val tz = if (settingsRepo.otherSettings.value.stateOfUtc) { + TimeZone.getTimeZone("UTC") + } else { + TimeZone.getDefault() + } + val offsetMillis = tz.getOffset(aosTime).toLong() val localMillis = Math.floorMod(aosTime + offsetMillis, 24L * 60L * 60L * 1000L) val aosMinute = (localMillis / 60_000L).toInt() val inRange = if (aosStartMinute <= aosEndMinute) { 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 e7468801..14f410d3 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 @@ -175,9 +175,12 @@ class PassesViewModel( val sdfDate = dateFormat(tz) val sdfTime = SimpleDateFormat("HH:mm", Locale.getDefault()).also { it.timeZone = tz } val result = LinkedHashMap>() - // DeepSpace group always shows today's sun times + // DeepSpace group always shows today's sun times. + // The natural-day anchor is the DEVICE timezone, not the display timezone: + // UTC midnight is 08:00 local for UTC+8 stations, when the sun is already + // up — that would trip the white-night guard and render "--:--". if (passes.any { it.isDeepSpace }) { - val riseSet = findTodaySunRiseSet(stationPos, startOfDayMillis(System.currentTimeMillis(), tz)) + val riseSet = findTodaySunRiseSet(stationPos, startOfDayMillis(System.currentTimeMillis(), TimeZone.getDefault())) val rise = if (riseSet.riseTimeMillis > 0) sdfTime.format(Date(riseSet.riseTimeMillis)) else "--:--" val set = if (riseSet.setTimeMillis > 0) sdfTime.format(Date(riseSet.setTimeMillis)) else "--:--" result["DeepSpace (period >225min)"] = rise to set @@ -186,7 +189,7 @@ class PassesViewModel( if (pass.isDeepSpace) continue val label = sdfDate.format(Date(pass.aosTime)) if (label in result) continue - val riseSet = findTodaySunRiseSet(stationPos, startOfDayMillis(pass.aosTime, tz)) + val riseSet = findTodaySunRiseSet(stationPos, startOfDayMillis(pass.aosTime, TimeZone.getDefault())) val rise = if (riseSet.riseTimeMillis > 0) sdfTime.format(Date(riseSet.riseTimeMillis)) else "--:--" val set = if (riseSet.setTimeMillis > 0) sdfTime.format(Date(riseSet.setTimeMillis)) else "--:--" result[label] = rise to set