mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-06-17 23:13:03 +08:00
fix(LibReserve): fix the failure to select nearest reserve time when the max time difference is 0
The previous implementation only considered the case when more than one nearest time exists, so we introduced the prefer_early flag to decide which one to be selected.But the comparsion mistakenly omitted the edge case when the difference is 0.
This commit is contained in:
+2
-2
@@ -403,9 +403,9 @@ class LibReserve(LibOperator):
|
||||
if abs_diff < best_time_diff or (
|
||||
abs_diff == best_time_diff and (
|
||||
# prefer earlier time
|
||||
(prefer_earlier and actual_diff < 0) or
|
||||
(prefer_earlier and actual_diff <= 0) or
|
||||
# prefer later time
|
||||
(not prefer_earlier and actual_diff > 0)
|
||||
(not prefer_earlier and actual_diff >= 0)
|
||||
)
|
||||
):
|
||||
best_time_diff = abs_diff
|
||||
|
||||
Reference in New Issue
Block a user