mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
fix(time): respect UTC toggle for AOS filter window and sunrise/sunset day anchor
- PassesViewModel: use the DEVICE timezone for the natural-day anchor in findTodaySunRiseSet instead of the display timezone. With UTC enabled the anchor was UTC midnight = 08:00 local for UTC+8 stations, when the sun is already up — tripping the white-night guard and rendering '--:--'. - SatelliteRepo.isAosInRange: follow the UTC display toggle so the pass time window is interpreted in UTC when UTC mode is on. Previously the list showed UTC times while the filter silently used local time, off by the timezone offset (8h for China).
This commit is contained in:
1 parent
2773145e0c
commit
7ef555e377
2 files changed
+16
-4
No files matched your search
+10
-1
@@ -175,7 +175,16 @@ class SatelliteRepo(
|
|||||||
aosEndMinute: Int,
|
aosEndMinute: Int,
|
||||||
invertAosTimeWindow: Boolean
|
invertAosTimeWindow: Boolean
|
||||||
): 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 localMillis = Math.floorMod(aosTime + offsetMillis, 24L * 60L * 60L * 1000L)
|
||||||
val aosMinute = (localMillis / 60_000L).toInt()
|
val aosMinute = (localMillis / 60_000L).toInt()
|
||||||
val inRange = if (aosStartMinute <= aosEndMinute) {
|
val inRange = if (aosStartMinute <= aosEndMinute) {
|
||||||
|
|||||||
+6
-3
@@ -175,9 +175,12 @@ class PassesViewModel(
|
|||||||
val sdfDate = dateFormat(tz)
|
val sdfDate = dateFormat(tz)
|
||||||
val sdfTime = SimpleDateFormat("HH:mm", Locale.getDefault()).also { it.timeZone = tz }
|
val sdfTime = SimpleDateFormat("HH:mm", Locale.getDefault()).also { it.timeZone = tz }
|
||||||
val result = LinkedHashMap<String, Pair<String, String>>()
|
val result = LinkedHashMap<String, Pair<String, String>>()
|
||||||
// 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 }) {
|
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 rise = if (riseSet.riseTimeMillis > 0) sdfTime.format(Date(riseSet.riseTimeMillis)) else "--:--"
|
||||||
val set = if (riseSet.setTimeMillis > 0) sdfTime.format(Date(riseSet.setTimeMillis)) else "--:--"
|
val set = if (riseSet.setTimeMillis > 0) sdfTime.format(Date(riseSet.setTimeMillis)) else "--:--"
|
||||||
result["DeepSpace (period >225min)"] = rise to set
|
result["DeepSpace (period >225min)"] = rise to set
|
||||||
@@ -186,7 +189,7 @@ class PassesViewModel(
|
|||||||
if (pass.isDeepSpace) continue
|
if (pass.isDeepSpace) continue
|
||||||
val label = sdfDate.format(Date(pass.aosTime))
|
val label = sdfDate.format(Date(pass.aosTime))
|
||||||
if (label in result) continue
|
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 rise = if (riseSet.riseTimeMillis > 0) sdfTime.format(Date(riseSet.riseTimeMillis)) else "--:--"
|
||||||
val set = if (riseSet.setTimeMillis > 0) sdfTime.format(Date(riseSet.setTimeMillis)) else "--:--"
|
val set = if (riseSet.setTimeMillis > 0) sdfTime.format(Date(riseSet.setTimeMillis)) else "--:--"
|
||||||
result[label] = rise to set
|
result[label] = rise to set
|
||||||
|
|||||||
Reference in new issue
Block a user