Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/SolarPublic

A Swift micro library for generating Sunrise and Sunset times.

License

NotificationsYou must be signed in to change notification settings

ceeK/Solar

Repository files navigation

Solar

VersionCarthage compatiblePOD compatibleSPM compatibleBuild StatusMIT licensed

A Swift helper for generating Sunrise and Sunset times.

Solar performs its calculations locally using an algorithm from theUnited States Naval Observatory, and thus does not require the use of a network.

Usage

Solar simply needs a date and a location specified as a latitude and longitude:

letsolar=Solar(for: someDate, coordinate:CLLocationCoordinate2D(latitude:51.528308, longitude:-0.1340267))letsunrise= solar?.sunriseletsunset= solar?.sunset

We can also omit providing a date if we just need the sunrise and sunset for the current date and time:

letsolar=Solar(coordinate:CLLocationCoordinate2D(latitude:51.528308, longitude:-0.1340267))letsunrise= solar?.sunriseletsunset= solar?.sunset

Note that all dates are UTC. Don't forget to format your date into the appropriate timezone if required.

Types of sunrise and sunset

There are several types of sunrise and sunset that Solar generates. They differ by how many degrees the sun lies below the horizon:

  • Official (~0°)

  • Civil (6° below horizon)

  • Nautical (12° below horizon)

  • Astronomical (18° below horizon)

For more information, seehttps://www.timeanddate.com/astronomy/different-types-twilight.html

Convenience methods

Solar also comes packaged with some convenience methods:

// Whether the location specified by the `latitude` and `longitude` is in daytime on `date`letisDaytime= solar.isDaytime// Whether the location specified by the `latitude` and `longitude` is in nighttime on `date`letisNighttime= solar.isNighttime

Installation

Solar is available through CocoaPods, Carthage, and Swift Package Manager.

CocoaPods

To include Solar in an application, add the followingpod to your Podfile, then runpod install:

pod"Solar-dev","~> 3.0"

To include Solar in another pod, add the followingdependency to your podspec:

s.dependency"Solar","~> 3.0"

Carthage

Add theceek/Solar project to yourCartfile, then follow the rest ofCarthage’s XCFramework installation instructions:

github"ceeK/Solar" ~>3.0

Swift Package Manager

To include Solar in an application in Xcode:

  1. Go to File ‣ Swift Packages ‣ Add Package Dependency.
  2. Enterhttps://github.com/ceeK/Solar.git as the package repository and click Next.
  3. Set Rules to Version, Up to Next Major, and enter3.0.0 as the minimum version requirement. Click Next.

To include Solar in another Swift package, add the followingdependency to your Package.swift:

.package(name:"Solar", url:"https://github.com/ceeK/Solar.git", from:"3.0.0")

License

The MIT License (MIT)

Copyright (c) 2016-2021 Chris Howell

Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 THESOFTWARE.

About

A Swift micro library for generating Sunrise and Sunset times.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp