SkillAgentSearch skills...

DayTimeCalculator

A small library to calculate sun rise and sun set time

Install / Use

/learn @olddonkey/DayTimeCalculator
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

DayTimeCalculator

</p>

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

View on GitHub
GitHub Stars22
CategoryDevelopment
Updated1mo ago
Forks4

Languages

Swift

Security Score

90/100

Audited on Feb 8, 2026

No findings