Twilight is a simple framework that calculates Sunrise, Sunset, and Twilight time based on the user's current location and time zone. This framework is based on sunriset.c created by Paul Schlyter and inspired by erndev's EDSunriseSet.
-
import Twilight
. -
Create a Twilight object and access values.
let now = NSDate()
let sunrise = Twilight(date: now, longtitude: longtitude, latitude: latitude).sunrise()
You can run the Test to test it's functionality.
Method | Documentation |
---|---|
sunrise() -> NSDate |
Get sunrise time. |
sunset()-> NSDate |
Get sunset time. |
twilight(type: Twilight.Type) -> (start: NSDate, end: NSDate) |
Get twilight start/end time for specified twilight type. |
daytimeLength() -> NSTimeInterval |
Get daytime length in seconds. |
twilightLength(type: Twilight.Type) -> NSTimeInterval |
Get twilight length for specified twilight type. |
Twilight types: .civil, .nautical, .astronomical. For more information, please refer to Twilight on Wikipedia
Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate Log into your Xcode project using Carthage, specify it in your Cartfile
:
github "kAzec/Twilight"
Copyright (c) 2016 and kAzec
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.