Go package for calculating the sunrise and sunset times for a given location
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml Ensure sudo is not used in Travis CI. Nov 21, 2017
LICENSE.txt Add license and badges to README. Oct 23, 2017
README.md Add goreportcard badge. Nov 21, 2017
anomaly.go Ensure output of SolarMeanAnomaly is in the range of 0 <= n < 360. Nov 21, 2017
anomaly_test.go Ensure correct positions are used in tests and fix issue with calcula… Nov 21, 2017
center.go Rename parameters. Nov 20, 2017
center_test.go Ensure correct positions are used in tests and fix issue with calcula… Nov 21, 2017
const.go Begin moving constants to a separate file. Nov 21, 2017
declination.go Move declination into separate function. Nov 21, 2017
declination_test.go Move declination into separate function. Nov 21, 2017
hourangle.go Move declination into separate function. Nov 21, 2017
hourangle_test.go Move declination into separate function. Nov 21, 2017
julian.go Add test for sunrise and sunset calculations. Nov 21, 2017
julian_test.go Ensure correct positions are used in tests and fix issue with calcula… Nov 21, 2017
longitude.go Rename parameters. Nov 20, 2017
longitude_test.go Minor conformity fix. Nov 21, 2017
noon.go Add function for calculating solar noon. Jun 15, 2017
noon_test.go Ensure correct positions are used in tests and fix issue with calcula… Nov 21, 2017
perihelion.go Move UpdatePerihelion into separate file and rename to ArgumentOfPeri… Nov 19, 2017
perihelion_test.go Ensure correct positions are used in tests and fix issue with calcula… Nov 21, 2017
round.go Rename a couple parameters. Nov 19, 2017
round_test.go Add test for Round function. Nov 19, 2017
sunrise.go Move declination into separate function. Nov 21, 2017
sunrise_test.go Correct computation error. Nov 21, 2017
transit.go Fix bug in calculating solar transit. Nov 21, 2017
transit_test.go Fix bug in calculating solar transit. Nov 21, 2017

README.md

go-sunrise

Build Status Coverage Status Go Report Card GoDoc MIT License

Go package for calculating the sunrise and sunset times for a given location based on this method.

Usage

To calculate sunrise and sunset times, you will need the following information:

  • the date for which you wish to calculate the times
  • the latitude and longitudinal coordinates of the location

Begin by importing the package:

import "github.com/nathan-osman/go-sunrise"

Next, feed the information into the SunriseSunset() method:

rise, set := sunrise.SunriseSunset(
    43.65, -79.38,          // Toronto, CA
    2000, time.January, 1,  // 2000-01-01
)

The two return values will be the sunrise and sunset times for the location on the given day as time.Time values.