RubySunrise Gem
Mon, Mar 15, 2010As a follow-up to the Java sunrise/sunset calculator I released early last year, I’m releasing a ruby gem that does essentially the same thing. Just in A LOT less code, but with the same attention to test goodness.
To install and use the RubySunrise gem just:
$ gem install RubySunrise
or download from RubyGems.
The current version as of today is 0.2, which requires the tzinfo gem to perform the timezone offset lookups.
If you want/need the lastest, just grab it from the github repo:
require ‘solareventcalculator’date = Date.parse(‘2008-11-01’) calc = SolarEventCalculator.new(date, BigDecimal.new(“39.9537”), BigDecimal.new(“-75.7850”))
utcOfficialSunrise = calc.compute_utc_official_sunrise localOfficialSunrise = calc.compute_official_sunrise(‘America/New_York’)
puts “utcOfficialSunrise #{utcOfficialSunrise}” puts “localOfficialSunrise #{localOfficialSunrise}”
Which yields:
utcOfficialSunrise 2008-11-01T11:33:00+00:00 localOfficialSunrise 2008-11-01T07:33:00-04:00
The source is available under the Apache License, Version 2.0 at Github