https://github.com/binarybirds/sunlight
Calculate dawn, dusk, golden and blue hour times by using various algorithms.
https://github.com/binarybirds/sunlight
calculator celestial dawn dusk sunrise sunset swift
Last synced: 6 months ago
JSON representation
Calculate dawn, dusk, golden and blue hour times by using various algorithms.
- Host: GitHub
- URL: https://github.com/binarybirds/sunlight
- Owner: BinaryBirds
- License: mit
- Created: 2019-02-11T21:41:50.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2022-02-17T15:19:05.000Z (over 3 years ago)
- Last Synced: 2025-04-05T23:15:06.618Z (6 months ago)
- Topics: calculator, celestial, dawn, dusk, sunrise, sunset, swift
- Language: Swift
- Homepage:
- Size: 6.84 KB
- Stars: 29
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sunlight (☀️)
Calculate dawn, dusk, golden and blue hour times by using various algorithms.
### Twilight Types

- Civil Twilight
- Nautical Twilight
- Astronomical Twilight
- Dawn (official)
- Dusk (official)
- The Golden Hour
- The Blue Hour## Usage
Some examples:
```swift
import Sunlightlet sunlight = SunlightCalculator(latitude: 47.49801, longitude: 19.03991)
let officialDawn = sunlight.calculate(.dawn, twilight: .official)
let officialDusk = sunlight.calculate(.dusk, twilight: .official)let civilDawn = sunlight.calculate(.dawn, twilight: .civil)
let civilDusk = sunlight.calculate(.dusk, twilight: .civil)let astronomicalDawn = sunlight.calculate(.dawn, twilight: .astronomical)
let astronomicalDusk = sunlight.calculate(.dusk, twilight: .astronomical)let nauticalDawn = sunlight.calculate(.dawn, twilight: .nautical)
let nauticalDusk = sunlight.calculate(.dusk, twilight: .nautical)let blueHourStart = sunlight.calculate(.dawn, twilight: .custom(-8))
let blueHourEndGoldenHourStart = sunlight.calculate(.dusk, twilight: .custom(-4))
let goldenHourEnd = sunlight.calculate(.dusk, twilight: .custom(6))```
## Install
Just use the [Swift Package Manager](https://theswiftdev.com/2017/11/09/swift-package-manager-tutorial/) as usual:
```swift
.package(url: "https://github.com/binarybirds/sunlight", from: "1.0.0"),
```⚠️ Don't forget to add "Sunlight" to your target as a dependency!
## License
[WTFPL](LICENSE) - Do what the fuck you want to.
## Other sources
- https://en.wikipedia.org/wiki/Position_of_the_Sun
- https://en.wikipedia.org/wiki/Sunrise_equation- https://www.codeproject.com/Articles/100174/Calculate-and-Draw-Moon-Phase
- http://lamminet.fi/jarmo/rscalc.cc
- https://www.timeanddate.com/astronomy/different-types-twilight.html
- https://www.photopills.com/articles/understanding-golden-hour-blue-hour-and-twilights