@@ -600,9 +600,7 @@ public struct Sun: Identifiable, Sendable {
600600 let secondsForSolarNoon = secondsForUTCSolarNoon + Double( timeZoneInSeconds)
601601 let startOfTheDay = calendar. startOfDay ( for: date)
602602
603- let hoursMinutesSeconds : ( Int , Int , Int ) = secondsToHoursMinutesSeconds ( Int ( secondsForSolarNoon) )
604-
605- let solarNoon = calendar. date ( bySettingHour: hoursMinutesSeconds. 0 , minute: hoursMinutesSeconds. 1 , second: hoursMinutesSeconds. 2 , of: startOfTheDay)
603+ let solarNoon = calendar. date ( byAdding: . second, value: Int ( secondsForSolarNoon) , to: startOfTheDay)
606604
607605 return solarNoon
608606 }
@@ -611,19 +609,17 @@ public struct Sun: Identifiable, Sendable {
611609 /// - Returns: Solar midnight time
612610 private func getSolarMidnight( ) -> Date ? {
613611
614- let secondsForUTCSolarMidnight = ( - 4 * location . coordinate . longitude - equationOfTime) * 60
615-
616- var calendarUTC : Calendar = . init( identifier: . gregorian)
617- calendarUTC. timeZone = . init( secondsFromGMT: 0 ) !
618-
619- let startOfTheDay = calendarUTC. startOfDay ( for: date)
620-
621- let solarMidnight = startOfTheDay. addingTimeInterval ( secondsForUTCSolarMidnight)
612+ let secondsForUTCSolarMidnight = ( 0 - 4 * location. coordinate. longitude - equationOfTime) * 60
613+ let secondsForSolarMidnight = secondsForUTCSolarMidnight + Double( timeZoneInSeconds)
614+ let startOfTheDay = calendar. startOfDay ( for: date)
622615
616+ let solarMidnight = calendar. date ( byAdding: . second, value: Int ( secondsForSolarMidnight) , to: startOfTheDay)
617+
623618 return solarMidnight
624619 }
625620
626621
622+
627623 /// Computes the Sunrise time for self.date
628624 /// - Returns: Sunrise time
629625 private func getSunrise( ) -> Date ? {
0 commit comments