Skip to content

Commit df215d2

Browse files
authored
Night goes from sunset to sunrise (#38)
1 parent 2f02378 commit df215d2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/SunKit/Sun.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ public class Sun {
157157
/// Returns True if is night
158158
public var isNight: Bool {
159159
if !isCircumPolar {
160-
return date < civilDusk || date > civilDawn
160+
return date < sunrise || date > sunset
161161
} else {
162162
return isAlwaysNight
163163
}
164164
}
165165

166166
/// Returns True if is twilight time
167167
public var isTwilight: Bool {
168-
(astronomicalDusk <= date && date <= sunrise) || (sunset <= date && date <= astronomicalDawn)
168+
(astronomicalDusk <= date && date < sunrise) || (sunset < date && date <= astronomicalDawn)
169169
}
170170

171171
/// Returns True if we are in evening golden hour range
@@ -201,11 +201,11 @@ public class Sun {
201201

202202
/// Returns true if we are near the pole and we are in a situation in which Sun Events during the day could have no meaning
203203
public var isCircumPolar: Bool {
204-
isAlwaysLight || isAlwaysNight
204+
isAlwaysDay || isAlwaysNight
205205
}
206206

207207
/// Returns true if for (Location,Date) is always daylight (e.g Tromso city in summer)
208-
public var isAlwaysLight: Bool {
208+
public var isAlwaysDay: Bool {
209209
let startOfTheDay = calendar.startOfDay(for: date)
210210
let almostNextDay = startOfTheDay + Double(SECONDS_IN_ONE_DAY)
211211

0 commit comments

Comments
 (0)