diff --git a/README.md b/README.md index 652472b..ff6b759 100644 --- a/README.md +++ b/README.md @@ -60,10 +60,10 @@ mySun.sunrise mySun.sunset // Evening Golden Hour Start Date -mySun.goldenHourStart +mySun.eveningGoldenHourStart // Evening Golden Hour End Date -mySun.goldenHourEnd +mySun.eveningGoldenHourEnd // To know all the information you can retrieve go to the **Features** section. @@ -96,17 +96,17 @@ To properly show the Sun Date Events use the following DateFormatter. ## Features * Sun Azimuth * Sun Altitude - * First Light Time - * Last Light Time + * Civil Dusk Time + * Civil Dawn Time * Sunrise Time * Solar Noon Time * Morning Golden Hour Time * Evening Golden Hour Time * Sunset Time - * Astronomical Sunrise - * Astronomical Sunset - * Nautical Sunrise - * Nautical Sunset + * Astronomical Dusk + * Astronomical Dawn + * Nautical Dusk + * Nautical Down * Morning Blue Hour Time * Evening Blue Hour Time * Sun Azimuth at Sunrise diff --git a/Sources/SunKit/Sun.swift b/Sources/SunKit/Sun.swift index 503f224..66c523b 100644 --- a/Sources/SunKit/Sun.swift +++ b/Sources/SunKit/Sun.swift @@ -41,9 +41,9 @@ public class Sun { public private(set) var solarNoon: Date = Date() ///Date at which evening evening Golden hour starts - public private(set) var goldenHourStart: Date = Date() + public private(set) var eveningGoldenHourStart: Date = Date() ///Date at which evening evening Golden hour ends - public private(set) var goldenHourEnd: Date = Date() + public private(set) var eveningGoldenHourEnd: Date = Date() ///Date at which evening Morning Golden hour starts public private(set) var morningGoldenHourStart: Date = Date() @@ -51,24 +51,24 @@ public class Sun { public private(set) var morningGoldenHourEnd: Date = Date() - ///Date at which there is the first light, also known as Civil Sunrise - public private(set) var firstLight: Date = Date() - ///Date at which there is the last light, also known as Civil Sunset - public private(set) var lastLight: Date = Date() + ///Date at which there is the Civil Dusk + public private(set) var civilDusk: Date = Date() + ///Date at which there is the Civil Dawn + public private(set) var civilDawn: Date = Date() - ///Date at which there is the Nautical Sunrise - public private(set) var nauticalSunrise: Date = Date() - ///Date at which there is the Nautical Sunset - public private(set) var nauticalSunset: Date = Date() + ///Date at which there is the Nautical Dusk + public private(set) var nauticalDusk: Date = Date() + ///Date at which there is the Nautical Down + public private(set) var nauticalDown: Date = Date() - ///Date at which there is the Astronomical Sunrise - public private(set) var astronomicalSunrise: Date = Date() - ///Date at which there is the Astronomical Sunset - public private(set) var astronomicalSunset: Date = Date() + ///Date at which there is the Astronomical Dusk + public private(set) var astronomicalDusk: Date = Date() + ///Date at which there is the Astronomical Dawn + public private(set) var astronomicalDawn: Date = Date() - ///Date at which morning Blue Hour starts. Sun at -6 degrees elevation = firstLight + ///Date at which morning Blue Hour starts. Sun at -6 degrees elevation = civil dusk public var morningBlueHourStart: Date{ - return firstLight + return civilDusk } ///Date at which morning Blue Hour ends. Sun at -4 degrees elevation = morning golden hour start @@ -78,12 +78,12 @@ public class Sun { ///Date at which evening Blue Hour starts. Sun at -4 degrees elevation = evening golden hour end public var eveningBlueHourStart: Date{ - return goldenHourEnd + return eveningGoldenHourEnd } - ///Date at which morning Blue Hour ends. Sun at -6 degrees elevation = last light + ///Date at which morning Blue Hour ends. Sun at -6 degrees elevation = Civil Dawn public var eveningBlueHourEnd: Date { - return lastLight + return civilDawn } @@ -157,27 +157,48 @@ public class Sun { /// Returns True if is night public var isNight: Bool { if !isCircumPolar { - return date < firstLight || date > lastLight + return date < civilDusk || date > civilDawn } else { return isAlwaysNight } } - /// Returns True if is sunrise - public var isSunrise: Bool { - date >= firstLight && date <= sunrise + /// Returns True if is twilight time + public var isTwilight: Bool { + (astronomicalDusk <= date && date <= sunrise) || (sunset <= date && date <= astronomicalDawn) } - /// Returns True if is sunset - public var isSunset: Bool { - date >= sunset && date <= lastLight + /// Returns True if we are in evening golden hour range + public var isEveningGoldenHour: Bool { + date.timeIntervalSince(eveningGoldenHourStart) >= 0 && eveningGoldenHourEnd.timeIntervalSince(date) >= 0 } - /// Returns True if we are in evening golden hour range + /// Returns True if we are in morning golden hour range + public var isMorningGoldenHour: Bool { + date.timeIntervalSince(morningBlueHourStart) >= 0 && morningBlueHourEnd.timeIntervalSince(date) >= 0 + } + + /// Returns True if we are in golden hour range public var isGoldenHour: Bool { - date.timeIntervalSince(goldenHourStart) >= 0 && goldenHourEnd.timeIntervalSince(date) >= 0 + isMorningGoldenHour || isEveningGoldenHour + } + + /// Returns True if we are in evening blue hour range + public var isEveningBlueHour: Bool { + date.timeIntervalSince(eveningBlueHourStart) >= 0 && eveningBlueHourEnd.timeIntervalSince(date) >= 0 } + /// Returns True if we are in morning blue hour range + public var isMorningBlueHour: Bool { + date.timeIntervalSince(morningBlueHourStart) >= 0 && morningBlueHourEnd.timeIntervalSince(date) >= 0 + } + + /// Returns True if we are in blue hour range + public var isBlueHour: Bool { + isMorningBlueHour || isEveningBlueHour + } + + /// 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 @@ -296,16 +317,16 @@ public class Sun { print("Sunrise -> \(dateFormatter.string(from: sunrise))") print("Sunset -> \(dateFormatter.string(from: sunset))") print("Solar Noon -> \(dateFormatter.string(from: solarNoon))") - print("evening Golden Hour Start -> \(dateFormatter.string(from: goldenHourStart))") - print("evening Golden Hour End -> \(dateFormatter.string(from: goldenHourEnd))") + print("Evening Golden Hour Start -> \(dateFormatter.string(from: eveningGoldenHourStart))") + print("Evening Golden Hour End -> \(dateFormatter.string(from: eveningGoldenHourEnd))") print("Morning Golden Hour Start -> \(dateFormatter.string(from: morningGoldenHourStart))") print("Morning Golden Hour End -> \(dateFormatter.string(from: morningGoldenHourEnd))") - print("First Light -> \(dateFormatter.string(from: firstLight))") - print("Last Light -> \(dateFormatter.string(from: lastLight))") - print("Nautical Sunrise -> \(dateFormatter.string(from: nauticalSunrise))") - print("Nautical Sunset -> \(dateFormatter.string(from: nauticalSunset))") - print("Astronomical Sunrise -> \(dateFormatter.string(from: astronomicalSunrise))") - print("Astronomical Sunset -> \(dateFormatter.string(from: astronomicalSunset))") + print("Civil dusk -> \(dateFormatter.string(from: civilDusk))") + print("Civil Dawn -> \(dateFormatter.string(from: civilDawn))") + print("Nautical Dusk -> \(dateFormatter.string(from: nauticalDusk))") + print("Nautical Down -> \(dateFormatter.string(from: nauticalDown))") + print("Astronomical Dusk -> \(dateFormatter.string(from: astronomicalDusk))") + print("Astronomical Dawn -> \(dateFormatter.string(from: astronomicalDawn))") print("Morning Blue Hour Start -> \(dateFormatter.string(from: morningBlueHourStart))") print("Morning Blue Hour End -> \(dateFormatter.string(from: morningBlueHourEnd))") print("evening Blue Hour Start -> \(dateFormatter.string(from: eveningBlueHourStart))") @@ -403,7 +424,7 @@ public class Sun { /// Then get rise, set and noon times and their relative azimuths in degrees. /// Compute Solar noon. /// Compute Golden hour start and end time. - /// Compute first light and last light time + /// Compute civil dusk and Civil Dawn time /// /// - Parameter needToComputeAgainSunEvents: True if Sunrise,Sunset and all the others daily sun events have to be computed. private func refresh(needToComputeSunEvents: Bool = true) { @@ -416,14 +437,14 @@ public class Sun { self.sunsetAzimuth = getSunHorizonCoordinatesFrom(date: sunset).azimuth.degrees self.solarNoon = getSolarNoon() ?? Date() self.solarNoonAzimuth = getSunHorizonCoordinatesFrom(date: solarNoon).azimuth.degrees - self.goldenHourStart = getGoldenHourStart() ?? Date() - self.goldenHourEnd = getGoldenHourFinish() ?? Date() - self.firstLight = getFirstLight() ?? Date() - self.lastLight = getLastLight() ?? Date() - self.nauticalSunrise = getNauticalSunrise() ?? Date() - self.nauticalSunset = getNauticalSunset() ?? Date() - self.astronomicalSunrise = getAstronomicalSunrise() ?? Date() - self.astronomicalSunset = getAstronomicalSunset() ?? Date() + self.eveningGoldenHourStart = getEveningGoldenHourStart() ?? Date() + self.eveningGoldenHourEnd = getEveningGoldenHourEnd() ?? Date() + self.civilDusk = getCivilDusk() ?? Date() + self.civilDawn = getCivilDawn() ?? Date() + self.nauticalDusk = getNauticalDusk() ?? Date() + self.nauticalDown = getNauticalDown() ?? Date() + self.astronomicalDusk = getAstronomicalDusk() ?? Date() + self.astronomicalDawn = getAstronomicalDawn() ?? Date() self.morningGoldenHourStart = getMorningGoldenHourStart() ?? Date() self.morningGoldenHourEnd = getMorningGoldenHourEnd() ?? Date() @@ -627,8 +648,8 @@ public class Sun { /// - Returns: Time at which the Sun reaches that elevation. Nil if it didn't find it. private func getDateFrom(sunEvent : SunElevationEvents, morning: Bool = false) -> Date? { - let elevationSunFirstLight: Angle = .degrees(sunEvent.rawValue) - var cosHra = (sin(elevationSunFirstLight.radians) - sin(sunEquatorialCoordinates.declination.radians) * sin(latitude.radians)) / (cos(sunEquatorialCoordinates.declination.radians) * cos(latitude.radians)) + let elevationSun: Angle = .degrees(sunEvent.rawValue) + var cosHra = (sin(elevationSun.radians) - sin(sunEquatorialCoordinates.declination.radians) * sin(latitude.radians)) / (cos(sunEquatorialCoordinates.declination.radians) * cos(latitude.radians)) cosHra = clamp(lower: -1, upper: 1, number: cosHra) let hraAngle: Angle = .radians(acos(cosHra)) var secondsForSunToReachElevation = (morning ? -1 : 1) * (hraAngle.degrees / 15) * SECONDS_IN_ONE_HOUR + TWELVE_HOUR_IN_SECONDS - timeCorrectionFactorInSeconds @@ -654,17 +675,17 @@ public class Sun { /// Golden Hour in the evening begins when the sun reaches elevation equals to 6 degrees /// - Returns: Time at which the GoldenHour starts - private func getGoldenHourStart() -> Date? { - guard let goldenHourStart = getDateFrom(sunEvent: .eveningGoldenHourStart) else { + private func getEveningGoldenHourStart() -> Date? { + guard let eveningGoldenHourStart = getDateFrom(sunEvent: .eveningGoldenHourStart) else { return nil } - return goldenHourStart + return eveningGoldenHourStart } /// Golden Hour in the evening ends when the sun reaches elevation equals to -4 degrees /// - Returns: Time at which the GoldenHour ends - private func getGoldenHourFinish() -> Date? { + private func getEveningGoldenHourEnd() -> Date? { guard let goldenHourFinish = getDateFrom(sunEvent: .eveningGoldenHourEnd) else { return nil } @@ -672,58 +693,58 @@ public class Sun { return goldenHourFinish } - /// Last light is when the Sun reaches -6 degrees of elevation. Also known as civil sunset. - /// - Returns: Last light time - private func getLastLight() -> Date? { - guard let lastLight = getDateFrom(sunEvent: .civil) else { + /// Civil Dawn is when the Sun reaches -6 degrees of elevation. Also known as civil sunset. + /// - Returns: Civil Dawn time + private func getCivilDawn() -> Date? { + guard let civilDawn = getDateFrom(sunEvent: .civil) else { return nil } - return lastLight + return civilDawn } - /// First light is when the Sun reaches -6 degrees of elevation. Also known as civil sunrise. - /// - Returns: First light time - private func getFirstLight() -> Date? { - guard let firstLight = getDateFrom(sunEvent: .civil, morning: true) else { + /// civil dusk is when the Sun reaches -6 degrees of elevation. Also known as civil sunrise. + /// - Returns: civil dusk time + private func getCivilDusk() -> Date? { + guard let civilDusk = getDateFrom(sunEvent: .civil, morning: true) else { return nil } - return firstLight + return civilDusk } - /// Nautical Sunrise is when the Sun reaches -12 degrees of elevation. - /// - Returns: Nautical Sunrise - private func getNauticalSunrise() -> Date? { - guard let nauticalSunrise = getDateFrom(sunEvent: .nautical, morning: true) else { + /// Nautical Dusk is when the Sun reaches -12 degrees of elevation. + /// - Returns: Nautical Dusk + private func getNauticalDusk() -> Date? { + guard let nauticalDusk = getDateFrom(sunEvent: .nautical, morning: true) else { return nil } - return nauticalSunrise + return nauticalDusk } - /// Nautical Sunrise is when the Sun reaches -12 degrees of elevation. - /// - Returns: Nautical Sunset - private func getNauticalSunset() -> Date? { - guard let nauticalSunset = getDateFrom(sunEvent: .nautical, morning: false) else { + /// Nautical Dusk is when the Sun reaches -12 degrees of elevation. + /// - Returns: Nautical Down + private func getNauticalDown() -> Date? { + guard let nauticalDown = getDateFrom(sunEvent: .nautical, morning: false) else { return nil } - return nauticalSunset + return nauticalDown } - /// Astronomical Sunrise is when the Sun reaches -18 degrees of elevation. - /// - Returns: Nautical Sunrise - private func getAstronomicalSunrise() -> Date? { - guard let nauticalSunrise = getDateFrom(sunEvent: .astronomical, morning: true) else { + /// Astronomical Dusk is when the Sun reaches -18 degrees of elevation. + /// - Returns: Astronomical Dusk + private func getAstronomicalDusk() -> Date? { + guard let astronomicalDusk = getDateFrom(sunEvent: .astronomical, morning: true) else { return nil } - return nauticalSunrise + return astronomicalDusk } - /// Astronomical Sunset is when the Sun reaches -18 degrees of elevation. - /// - Returns: Nautical Sunset - private func getAstronomicalSunset() -> Date? { - guard let nauticalSunset = getDateFrom(sunEvent: .astronomical, morning: false) else { + /// Astronomical Dawn is when the Sun reaches -18 degrees of elevation. + /// - Returns: Astronomical Dawn + private func getAstronomicalDawn() -> Date? { + guard let astronomicalDawn = getDateFrom(sunEvent: .astronomical, morning: false) else { return nil } - return nauticalSunset + return astronomicalDawn } /// Morning Golden Hour start when Sun reaches -4 degress of elevation diff --git a/Tests/SunKitTests/UT_Sun.swift b/Tests/SunKitTests/UT_Sun.swift index 5888984..9757330 100644 --- a/Tests/SunKitTests/UT_Sun.swift +++ b/Tests/SunKitTests/UT_Sun.swift @@ -93,18 +93,18 @@ final class UT_Sun: XCTestCase { var expectedGoldenHourStart = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 16, minute: 00, seconds: 00,timeZone: timeZoneUnderTest) var expectedGoldenHourEnd = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 16, minute: 59, seconds: 00,timeZone: timeZoneUnderTest) - var expectedFirstLight = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 6, minute: 24, seconds: 51,timeZone: timeZoneUnderTest) - var expectedLastLight = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 17, minute: 11, seconds: 28,timeZone: timeZoneUnderTest) + var expectedcivilDusk = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 6, minute: 24, seconds: 51,timeZone: timeZoneUnderTest) + var expectedcivilDawn = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 17, minute: 11, seconds: 28,timeZone: timeZoneUnderTest) var expectedSolarNoon = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 11, minute: 48, seconds: 21,timeZone: timeZoneUnderTest) - var expectedNauticalSunrise = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 5, minute: 52, seconds: 21,timeZone: timeZoneUnderTest) + var expectednauticalDusk = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 5, minute: 52, seconds: 21,timeZone: timeZoneUnderTest) - var expectedNauticalSunset = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 17, minute: 44, seconds: 45,timeZone: timeZoneUnderTest) + var expectednauticalDown = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 17, minute: 44, seconds: 45,timeZone: timeZoneUnderTest) - var expectedAstronomicalSunrise = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 5, minute: 19, seconds: 25,timeZone: timeZoneUnderTest) + var expectedastronomicalDusk = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 5, minute: 19, seconds: 25,timeZone: timeZoneUnderTest) - var expectedAstronomicalSunset = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 18, minute: 17, seconds: 20,timeZone: timeZoneUnderTest) + var expectedastronomicalDawn = createDateCustomTimeZone(day: 19, month: 11, year: 2022, hour: 18, minute: 17, seconds: 20,timeZone: timeZoneUnderTest) //Step4: Check if the output are close to the expected ones @@ -115,20 +115,20 @@ final class UT_Sun: XCTestCase { XCTAssertTrue(abs(expectedSunRise.timeIntervalSince1970 - sunUnderTest.sunrise.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSunset.timeIntervalSince1970 - sunUnderTest.sunset.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedGoldenHourStart.timeIntervalSince1970 - sunUnderTest.goldenHourStart.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedGoldenHourEnd.timeIntervalSince1970 - sunUnderTest.goldenHourEnd.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedGoldenHourStart.timeIntervalSince1970 - sunUnderTest.eveningGoldenHourStart.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedGoldenHourEnd.timeIntervalSince1970 - sunUnderTest.eveningGoldenHourEnd.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedFirstLight.timeIntervalSince1970 - sunUnderTest.firstLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedLastLight.timeIntervalSince1970 - sunUnderTest.lastLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDusk.timeIntervalSince1970 - sunUnderTest.civilDusk.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDawn.timeIntervalSince1970 - sunUnderTest.civilDawn.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSolarNoon.timeIntervalSince1970 - sunUnderTest.solarNoon.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedNauticalSunrise.timeIntervalSince1970 - sunUnderTest.nauticalSunrise.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedNauticalSunset.timeIntervalSince1970 - sunUnderTest.nauticalSunset.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectednauticalDusk.timeIntervalSince1970 - sunUnderTest.nauticalDusk.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectednauticalDown.timeIntervalSince1970 - sunUnderTest.nauticalDown.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedAstronomicalSunrise.timeIntervalSince1970 - sunUnderTest.astronomicalSunrise.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedastronomicalDusk.timeIntervalSince1970 - sunUnderTest.astronomicalDusk.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedAstronomicalSunset.timeIntervalSince1970 - sunUnderTest.astronomicalSunset.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedastronomicalDawn.timeIntervalSince1970 - sunUnderTest.astronomicalDawn.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) //Test: 31/12/2024 15:32. Timezone +1. Leap Year. @@ -152,8 +152,8 @@ final class UT_Sun: XCTestCase { expectedGoldenHourStart = createDateCustomTimeZone(day: 31, month: 12, year: 2024, hour: 16, minute: 02, seconds: 00,timeZone: timeZoneUnderTest) expectedGoldenHourEnd = createDateCustomTimeZone(day: 31, month: 12, year: 2024, hour: 17, minute: 05, seconds: 00,timeZone: timeZoneUnderTest) - expectedFirstLight = createDateCustomTimeZone(day: 31, month: 12, year: 2024, hour: 6, minute: 56, seconds: 24,timeZone: timeZoneUnderTest) - expectedLastLight = createDateCustomTimeZone(day: 31, month: 12, year: 2024, hour: 17, minute: 16, seconds: 06,timeZone: timeZoneUnderTest) + expectedcivilDusk = createDateCustomTimeZone(day: 31, month: 12, year: 2024, hour: 6, minute: 56, seconds: 24,timeZone: timeZoneUnderTest) + expectedcivilDawn = createDateCustomTimeZone(day: 31, month: 12, year: 2024, hour: 17, minute: 16, seconds: 06,timeZone: timeZoneUnderTest) expectedSolarNoon = createDateCustomTimeZone(day: 31, month: 12, year: 2024, hour: 12, minute: 06, seconds: 11,timeZone: timeZoneUnderTest) @@ -165,11 +165,11 @@ final class UT_Sun: XCTestCase { XCTAssertTrue(abs(expectedSunRise.timeIntervalSince1970 - sunUnderTest.sunrise.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSunset.timeIntervalSince1970 - sunUnderTest.sunset.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedGoldenHourStart.timeIntervalSince1970 - sunUnderTest.goldenHourStart.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedGoldenHourEnd.timeIntervalSince1970 - sunUnderTest.goldenHourEnd.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedGoldenHourStart.timeIntervalSince1970 - sunUnderTest.eveningGoldenHourStart.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedGoldenHourEnd.timeIntervalSince1970 - sunUnderTest.eveningGoldenHourEnd.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedFirstLight.timeIntervalSince1970 - sunUnderTest.firstLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedLastLight.timeIntervalSince1970 - sunUnderTest.lastLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDusk.timeIntervalSince1970 - sunUnderTest.civilDusk.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDawn.timeIntervalSince1970 - sunUnderTest.civilDawn.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSolarNoon.timeIntervalSince1970 - sunUnderTest.solarNoon.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) @@ -198,8 +198,8 @@ final class UT_Sun: XCTestCase { expectedGoldenHourStart = createDateCustomTimeZone(day: 1, month: 8, year: 2022, hour: 18, minute: 11, seconds: 00,timeZone: timeZoneUnderTest) expectedGoldenHourEnd = createDateCustomTimeZone(day: 1, month: 8, year: 2022, hour: 19, minute: 04, seconds: 00,timeZone: timeZoneUnderTest) - expectedFirstLight = createDateCustomTimeZone(day: 1, month: 8, year: 2022, hour: 4, minute: 20, seconds: 39,timeZone: timeZoneUnderTest) - expectedLastLight = createDateCustomTimeZone(day: 1, month: 8, year: 2022, hour: 19, minute: 14, seconds: 00,timeZone: timeZoneUnderTest) + expectedcivilDusk = createDateCustomTimeZone(day: 1, month: 8, year: 2022, hour: 4, minute: 20, seconds: 39,timeZone: timeZoneUnderTest) + expectedcivilDawn = createDateCustomTimeZone(day: 1, month: 8, year: 2022, hour: 19, minute: 14, seconds: 00,timeZone: timeZoneUnderTest) expectedSolarNoon = createDateCustomTimeZone(day: 1, month: 8, year: 2022, hour: 11, minute: 47, seconds: 36,timeZone: timeZoneUnderTest) @@ -211,11 +211,11 @@ final class UT_Sun: XCTestCase { XCTAssertTrue(abs(expectedSunRise.timeIntervalSince1970 - sunUnderTest.sunrise.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSunset.timeIntervalSince1970 - sunUnderTest.sunset.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedGoldenHourStart.timeIntervalSince1970 - sunUnderTest.goldenHourStart.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedGoldenHourEnd.timeIntervalSince1970 - sunUnderTest.goldenHourEnd.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedGoldenHourStart.timeIntervalSince1970 - sunUnderTest.eveningGoldenHourStart.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedGoldenHourEnd.timeIntervalSince1970 - sunUnderTest.eveningGoldenHourEnd.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedFirstLight.timeIntervalSince1970 - sunUnderTest.firstLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedLastLight.timeIntervalSince1970 - sunUnderTest.lastLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDusk.timeIntervalSince1970 - sunUnderTest.civilDusk.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDawn.timeIntervalSince1970 - sunUnderTest.civilDawn.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSolarNoon.timeIntervalSince1970 - sunUnderTest.solarNoon.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) @@ -243,8 +243,8 @@ final class UT_Sun: XCTestCase { expectedGoldenHourStart = createDateCustomTimeZone(day: 1, month: 1, year: 2015, hour: 16, minute: 22, seconds: 00,timeZone: timeZoneUnderTest) expectedGoldenHourEnd = createDateCustomTimeZone(day: 1, month: 1, year: 2015, hour: 17, minute: 22, seconds: 00,timeZone: timeZoneUnderTest) - expectedFirstLight = createDateCustomTimeZone(day: 1, month: 1, year: 2015, hour: 6, minute: 58, seconds: 28,timeZone: timeZoneUnderTest) - expectedLastLight = createDateCustomTimeZone(day: 1, month: 1, year: 2015, hour: 17, minute: 32, seconds: 27,timeZone: timeZoneUnderTest) + expectedcivilDusk = createDateCustomTimeZone(day: 1, month: 1, year: 2015, hour: 6, minute: 58, seconds: 28,timeZone: timeZoneUnderTest) + expectedcivilDawn = createDateCustomTimeZone(day: 1, month: 1, year: 2015, hour: 17, minute: 32, seconds: 27,timeZone: timeZoneUnderTest) expectedSolarNoon = createDateCustomTimeZone(day: 1, month: 1, year: 2015, hour: 12, minute: 15, seconds: 23,timeZone: timeZoneUnderTest) @@ -256,11 +256,11 @@ final class UT_Sun: XCTestCase { XCTAssertTrue(abs(expectedSunRise.timeIntervalSince1970 - sunUnderTest.sunrise.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSunset.timeIntervalSince1970 - sunUnderTest.sunset.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedGoldenHourStart.timeIntervalSince1970 - sunUnderTest.goldenHourStart.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedGoldenHourEnd.timeIntervalSince1970 - sunUnderTest.goldenHourEnd.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedGoldenHourStart.timeIntervalSince1970 - sunUnderTest.eveningGoldenHourStart.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedGoldenHourEnd.timeIntervalSince1970 - sunUnderTest.eveningGoldenHourEnd.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedFirstLight.timeIntervalSince1970 - sunUnderTest.firstLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedLastLight.timeIntervalSince1970 - sunUnderTest.lastLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDusk.timeIntervalSince1970 - sunUnderTest.civilDusk.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDawn.timeIntervalSince1970 - sunUnderTest.civilDawn.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSolarNoon.timeIntervalSince1970 - sunUnderTest.solarNoon.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) @@ -284,8 +284,8 @@ final class UT_Sun: XCTestCase { expectedSunRise = createDateCustomTimeZone(day: 19, month: 1, year: 2022, hour: 10, minute: 41, seconds: 46,timeZone: timeZoneUnderTest) expectedSunset = createDateCustomTimeZone(day: 19, month: 1, year: 2022, hour: 13, minute: 08, seconds: 48,timeZone: timeZoneUnderTest) - expectedFirstLight = createDateCustomTimeZone(day: 19, month: 1, year: 2022, hour: 08, minute: 45, seconds: 30,timeZone: timeZoneUnderTest) - expectedLastLight = createDateCustomTimeZone(day: 19, month: 1, year: 2022, hour: 15, minute: 05, seconds: 08,timeZone: timeZoneUnderTest) + expectedcivilDusk = createDateCustomTimeZone(day: 19, month: 1, year: 2022, hour: 08, minute: 45, seconds: 30,timeZone: timeZoneUnderTest) + expectedcivilDawn = createDateCustomTimeZone(day: 19, month: 1, year: 2022, hour: 15, minute: 05, seconds: 08,timeZone: timeZoneUnderTest) expectedSolarNoon = createDateCustomTimeZone(day: 19, month: 1, year: 2022, hour: 11, minute: 54, seconds: 52,timeZone: timeZoneUnderTest) @@ -296,8 +296,8 @@ final class UT_Sun: XCTestCase { XCTAssertTrue(abs(expectedSunRise.timeIntervalSince1970 - sunUnderTest.sunrise.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSunset.timeIntervalSince1970 - sunUnderTest.sunset.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedFirstLight.timeIntervalSince1970 - sunUnderTest.firstLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedLastLight.timeIntervalSince1970 - sunUnderTest.lastLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDusk.timeIntervalSince1970 - sunUnderTest.civilDusk.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDawn.timeIntervalSince1970 - sunUnderTest.civilDawn.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSolarNoon.timeIntervalSince1970 - sunUnderTest.solarNoon.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) @@ -321,8 +321,8 @@ final class UT_Sun: XCTestCase { expectedSunRise = createDateCustomTimeZone(day: 12, month: 3, year: 2023, hour: 6, minute: 49, seconds: 35,timeZone: timeZoneUnderTest) expectedSunset = createDateCustomTimeZone(day: 12, month: 3, year: 2023, hour: 18, minute: 47, seconds: 42,timeZone: timeZoneUnderTest) - expectedFirstLight = createDateCustomTimeZone(day: 12, month: 3, year: 2023, hour: 6, minute: 27, seconds: 59,timeZone: timeZoneUnderTest) - expectedLastLight = createDateCustomTimeZone(day: 12, month: 3, year: 2023, hour: 19, minute: 09, seconds: 19,timeZone: timeZoneUnderTest) + expectedcivilDusk = createDateCustomTimeZone(day: 12, month: 3, year: 2023, hour: 6, minute: 27, seconds: 59,timeZone: timeZoneUnderTest) + expectedcivilDawn = createDateCustomTimeZone(day: 12, month: 3, year: 2023, hour: 19, minute: 09, seconds: 19,timeZone: timeZoneUnderTest) expectedSolarNoon = createDateCustomTimeZone(day: 12, month: 3, year: 2023, hour: 12, minute: 48, seconds: 31,timeZone: timeZoneUnderTest) @@ -333,8 +333,8 @@ final class UT_Sun: XCTestCase { XCTAssertTrue(abs(expectedSunRise.timeIntervalSince1970 - sunUnderTest.sunrise.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSunset.timeIntervalSince1970 - sunUnderTest.sunset.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedFirstLight.timeIntervalSince1970 - sunUnderTest.firstLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) - XCTAssertTrue(abs(expectedLastLight.timeIntervalSince1970 - sunUnderTest.lastLight.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDusk.timeIntervalSince1970 - sunUnderTest.civilDusk.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) + XCTAssertTrue(abs(expectedcivilDawn.timeIntervalSince1970 - sunUnderTest.civilDawn.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds) XCTAssertTrue(abs(expectedSolarNoon.timeIntervalSince1970 - sunUnderTest.solarNoon.timeIntervalSince1970) < UT_Sun.sunSetRiseThresholdInSeconds)