Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nathan-osman/go-sunrise
Go package for calculating the sunrise and sunset times for a given location
https://github.com/nathan-osman/go-sunrise
astronomy calendar golang sunrise sunset
Last synced: 7 days ago
JSON representation
Go package for calculating the sunrise and sunset times for a given location
- Host: GitHub
- URL: https://github.com/nathan-osman/go-sunrise
- Owner: nathan-osman
- License: mit
- Created: 2017-06-15T20:49:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-23T10:07:48.000Z (8 months ago)
- Last Synced: 2024-07-31T20:50:57.564Z (5 months ago)
- Topics: astronomy, calendar, golang, sunrise, sunset
- Language: Go
- Size: 59.6 KB
- Stars: 142
- Watchers: 7
- Forks: 17
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-go - go-sunrise - Calculate the sunrise and sunset times for a given location. (Date and Time / Search and Analytic Databases)
- awesome-go - go-sunrise - Go package for calculating the sunrise and sunset times for a given location - ★ 8 (Date and Time)
- awesome-go-extra - go-sunrise - 06-15T20:49:41Z|2021-06-07T17:58:34Z| (Date and Time / Advanced Console UIs)
README
## go-sunrise
[![Build Status](https://app.travis-ci.com/nathan-osman/go-sunrise.svg?branch=master)](https://app.travis-ci.com/nathan-osman/go-sunrise)
[![Coverage Status](https://coveralls.io/repos/github/nathan-osman/go-sunrise/badge.svg?branch=master)](https://coveralls.io/github/nathan-osman/go-sunrise?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/nathan-osman/go-sunrise)](https://goreportcard.com/report/github.com/nathan-osman/go-sunrise)
[![GoDoc](https://godoc.org/github.com/nathan-osman/go-sunrise?status.svg)](https://godoc.org/github.com/nathan-osman/go-sunrise)
[![MIT License](http://img.shields.io/badge/license-MIT-9370d8.svg?style=flat)](http://opensource.org/licenses/MIT)Go package for calculating the sunrise and sunset times for a given location based on [this method](https://en.wikipedia.org/wiki/Sunrise_equation#Complete_calculation_on_Earth).
### 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 locationBegin 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. If sun does not rise or set, both return values will be time.Time{}.