Latest 1.0.0
Homepage https://github.com/olddonkey/DayTimeCalculator
License MIT
Platforms ios 8.0, requires ARC
Frameworks Foundation
Authors

A small library to calculate sun rise and sun set time. Provide latitude and longitude, return an UTC Date that’s day’s sun rise or sun set time. The time zone used during calculation is system time zone. This can avoid a lot of problems.

Features

  • [x] Only need latitude and longitude, no need for network
  • [x] One line to use this service

Usage

Use CocoaPods or Cathage or just pull the DayTimeCalculator.swift file into your project.

CocoaPods:

To integrate DayTimeCalculator into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'your_app' do
  pod 'DayTimeCalculator', '~> 1.0.0'
end

Then, run the following command:

$ pod install

You should open the {Project}.xcworkspace instead of the {Project}.xcodeproj after you installed anything from CocoaPods.

Manully:

Drag the DayTimeCalculator.swift file into your project

//date is the returned valued
let date = DayTimeCalculator.getSunRiseSetTime(date: Your date(Date() Type), lat: Your latitude, lng: Your longtitude, timeType: .sunRise or .sunSet)

Requirements

  • iOS 8.0+
  • Swift 3

The main development of DayTimeCalculator is based on Swift 3.

Contact

Follow and contact me through email. If you find an issue, just open a ticket on it. Pull requests are warmly welcome as well.

License

DayTimeCalculator is released under the MIT license. See LICENSE for details.

Kudos

Thanks to @junlincao for his algorithm in Java

Latest podspec

{
    "name": "DayTimeCalculator",
    "version": "1.0.0",
    "summary": "DayTime Calculator is a tool to help me calculate sunrise and sunset time",
    "description": "A small library to calculate sun rise and sun set time. Provide latitude and longitude, return an UTC Date that's that day's sun rise or sun set time",
    "homepage": "https://github.com/olddonkey/DayTimeCalculator",
    "license": "MIT",
    "authors": {
        "olddonkey": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/olddonkey/DayTimeCalculator.git",
        "tag": "1.0.0"
    },
    "source_files": [
        "DayTimeCalculator/*.swift",
        "DayTimeCalculator/Source/*.swift"
    ],
    "frameworks": "Foundation",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3.0"
    },
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This