From 9d47ca3af4ec7c035f98a5e7e7f9e7c35657ee15 Mon Sep 17 00:00:00 2001 From: LEO Yoon-Tsaw Date: Sun, 7 Nov 2021 14:58:55 -0500 Subject: [PATCH] follow up fix --- ChineseTime/Model.swift | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ChineseTime/Model.swift b/ChineseTime/Model.swift index 976b71c..4dba8e0 100644 --- a/ChineseTime/Model.swift +++ b/ChineseTime/Model.swift @@ -557,13 +557,8 @@ class ChineseCalendar { } var eventInHour: CelestialEvent { let currentHour = self.currentHour - let hourStart = _calendar.date(bySettingHour: Int(currentHour / 2) * 2, minute: 0, second: 0, of: _time)! - let nextHourStart: Date - if currentHour / 2 < 11 { - nextHourStart = _calendar.date(bySettingHour: (Int(currentHour / 2)+1) * 2, minute: 0, second: 0, of: _time)! - } else { - nextHourStart = _calendar.startOfDay(for: _calendar.date(byAdding: .day, value: 1, to: _time)!) - } + let hourStart = _time.advanced(by: -(currentHour % 2.0) * 3600) + let nextHourStart = hourStart.advanced(by: 7200) var event = CelestialEvent() event.eclipse = _moonEclipses.filter { hourStart <= $0 && nextHourStart > $0 }.map { date in hourStart.distance(to: date) / 7200