Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Calculate sunrise and sunset times for a given time and place
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib Update licensing
spec Add code coverage for Ruby >= 1.9
.gitignore
.rspec Switch to Rspec
.travis.yml Also run Travis against Ruby 2.1.0
COPYING Update licensing
Gemfile Extract a gemspec
README.md Indicate origianl source of algorithm
Rakefile Switch to Rspec
ruby-sun-times.gemspec

README.md

ruby-sun-times Build Status

Calculates sunrise and sunset times

The algorithm comes from the Almanac for computers.

Usage

Requiring

In a Gemfile/Gemspec:

gem 'ruby-sun-times', require: 'sun_times'

Directly:

require 'sun_times'

Methods

The two methods rise and set each return a Time.

day = Date.new(2010, 3, 8)
latitude = 43.779
longitude = 11.432
sun_times = SunTimes.new
sun_times.rise(day, latitude, longitude) # => 2010-03-08 05:39:53 UTC
sun_times.set(day, latitude, longitude) # => 2010-03-08 17:11:16 UTC

References

Something went wrong with that request. Please try again.