diff options
Diffstat (limited to 'Solsnu.Widget')
| -rw-r--r-- | Solsnu.Widget/Utilities/SunTimes.swift | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Solsnu.Widget/Utilities/SunTimes.swift b/Solsnu.Widget/Utilities/SunTimes.swift index f8906ce..d3ca7fc 100644 --- a/Solsnu.Widget/Utilities/SunTimes.swift +++ b/Solsnu.Widget/Utilities/SunTimes.swift @@ -73,8 +73,8 @@ class SunTimes { let sunsetLocal = sunsetUTC + tzOffset // Step 9: Create date components, handling day boundary crossing - let calendar2 = Calendar.current - var baseComponents = calendar2.dateComponents([.year, .month, .day], from: date) + let currentCalendar = Calendar.current + var baseComponents = currentCalendar.dateComponents([.year, .month, .day], from: date) // Sunrise var sunriseComp = baseComponents @@ -84,16 +84,16 @@ class SunTimes { let srMinute = Int(srMinuteDouble) if srHour < 0 { - if let prevDay = calendar2.date(byAdding: .day, value: -1, to: date) { - let prevComponents = calendar2.dateComponents([.year, .month, .day], from: prevDay) + if let prevDay = currentCalendar.date(byAdding: .day, value: -1, to: date) { + let prevComponents = currentCalendar.dateComponents([.year, .month, .day], from: prevDay) sunriseComp = prevComponents sunriseComp.hour = 24 + srHour } else { sunriseComp.hour = 0 } } else if srHour >= 24 { - if let nextDay = calendar2.date(byAdding: .day, value: 1, to: date) { - let nextComponents = calendar2.dateComponents([.year, .month, .day], from: nextDay) + if let nextDay = currentCalendar.date(byAdding: .day, value: 1, to: date) { + let nextComponents = currentCalendar.dateComponents([.year, .month, .day], from: nextDay) sunriseComp = nextComponents sunriseComp.hour = srHour - 24 } else { @@ -113,16 +113,16 @@ class SunTimes { let ssMinute = Int(ssMinuteDouble) if ssHour < 0 { - if let prevDay = calendar2.date(byAdding: .day, value: -1, to: date) { - let prevComponents = calendar2.dateComponents([.year, .month, .day], from: prevDay) + if let prevDay = currentCalendar.date(byAdding: .day, value: -1, to: date) { + let prevComponents = currentCalendar.dateComponents([.year, .month, .day], from: prevDay) sunsetComp = prevComponents sunsetComp.hour = 24 + ssHour } else { sunsetComp.hour = 0 } } else if ssHour >= 24 { - if let nextDay = calendar2.date(byAdding: .day, value: 1, to: date) { - let nextComponents = calendar2.dateComponents([.year, .month, .day], from: nextDay) + if let nextDay = currentCalendar.date(byAdding: .day, value: 1, to: date) { + let nextComponents = currentCalendar.dateComponents([.year, .month, .day], from: nextDay) sunsetComp = nextComponents sunsetComp.hour = ssHour - 24 } else { @@ -134,8 +134,8 @@ class SunTimes { sunsetComp.minute = max(0, min(59, ssMinute)) sunsetComp.second = 0 - guard let sunriseDate = calendar2.date(from: sunriseComp), - let sunsetDate = calendar2.date(from: sunsetComp) else { + guard let sunriseDate = currentCalendar.date(from: sunriseComp), + let sunsetDate = currentCalendar.date(from: sunsetComp) else { return nil } |
