Skip to content

Commit

Permalink
Night goes from sunset to sunrise (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
seldon1000 authored Apr 27, 2023
1 parent 2f02378 commit df215d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Binary file not shown.
8 changes: 4 additions & 4 deletions Sources/SunKit/Sun.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ public class Sun {
/// Returns True if is night
public var isNight: Bool {
if !isCircumPolar {
return date < civilDusk || date > civilDawn
return date < sunrise || date > sunset
} else {
return isAlwaysNight
}
}

/// Returns True if is twilight time
public var isTwilight: Bool {
(astronomicalDusk <= date && date <= sunrise) || (sunset <= date && date <= astronomicalDawn)
(astronomicalDusk <= date && date < sunrise) || (sunset < date && date <= astronomicalDawn)
}

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

/// 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
public var isCircumPolar: Bool {
isAlwaysLight || isAlwaysNight
isAlwaysDay || isAlwaysNight
}

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

Expand Down

0 comments on commit df215d2

Please sign in to comment.