{"id":37224514,"url":"https://github.com/observerly/dusk","last_synced_at":"2026-01-15T01:42:02.972Z","repository":{"id":37080508,"uuid":"457794769","full_name":"observerly/dusk","owner":"observerly","description":"🌑 Dusk is a Go library for calculating astronomical twilight, the lunar phase and the rise and set times of the moon and sun.","archived":false,"fork":false,"pushed_at":"2023-03-02T17:34:42.000Z","size":248,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-08T13:13:49.593Z","etag":null,"topics":["amateur-astronomy","astronomy","dawn","dusk","lunar","night","solar","twilight"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/observerly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-02-10T13:37:56.000Z","updated_at":"2024-09-23T00:02:27.000Z","dependencies_parsed_at":"2022-06-24T16:34:09.334Z","dependency_job_id":"335a9320-2500-4e21-bcee-5ec9c0926eaf","html_url":"https://github.com/observerly/dusk","commit_stats":{"total_commits":174,"total_committers":3,"mean_commits":58.0,"dds":0.09195402298850575,"last_synced_commit":"a10ef80d84c122c209218178be7b79877433d04c"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/observerly/dusk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/observerly%2Fdusk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/observerly%2Fdusk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/observerly%2Fdusk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/observerly%2Fdusk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/observerly","download_url":"https://codeload.github.com/observerly/dusk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/observerly%2Fdusk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28441031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:55:22.719Z","status":"ssl_error","status_checked_at":"2026-01-15T00:55:20.945Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amateur-astronomy","astronomy","dawn","dusk","lunar","night","solar","twilight"],"created_at":"2026-01-15T01:42:02.208Z","updated_at":"2026-01-15T01:42:02.954Z","avatar_url":"https://github.com/observerly.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![@observerly/dusk](https://user-images.githubusercontent.com/84131395/172596337-7499f919-3e41-48ea-a561-b88afa75b8c9.png)\n\n![GitHub go.mod Go version (branch \u0026 subdirectory of monorepo)](https://img.shields.io/github/go-mod/go-version/observerly/dusk/main?filename=go.mod\u0026label=Go)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/observerly/dusk)](https://pkg.go.dev/github.com/observerly/dusk)\n[![Go Report Card](https://goreportcard.com/badge/github.com/observerly/dusk)](https://goreportcard.com/report/github.com/observerly/dusk)\n[![Dusk Actions Status](https://github.com/observerly/dusk/actions/workflows/ci.yml/badge.svg)](https://github.com/observerly/celestia/actions/workflows/ci.yml)\n\nDusk 🌑 is a minimal dependency Go library for calculating the most opinimum time to observe various astronomical objects by utilising paramaters such as astronomical twilight, the lunar phase and the rise and set times of the moon and sun.\n\n## Installation\n\nMake sure you have Go installed ([download](https://golang.org/dl/)). Version `1.17` or higher is required for this package.\n\nInitialize your project by creating a folder and then running `go mod init github.com/your/repo` ([learn more](https://blog.golang.org/using-go-modules)) inside the folder. Then install Dusk with the [`go get`](https://golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them) command:\n\n```bash\ngo get -u github.com/observerly/dusk\n```\n\n## Usage\n\n### Get Twilight\n\nThe basic usage of this package is to use the `GetLocalTwilight()` func, this provides the Sun rise and Sun set times (in datetime format, as local time), it also provides the \"duration\" between these two datetimes. The local time is calculated from a UTC date for the speicif latitude and longitude coordiantes provided.\n\n```go\npackage main\n\nimport (\n  \"time\"\n\n  \"github.com/observerly/dusk/pkg/dusk\"\n)\n\nfunc main() {\n  // datetime of observation:\n  datetime := time.Date(2022, 2, 17, 0, 0, 0, 0, time.UTC)\n\n  // observer's longitude, in degrees (*west of the Greenwhich meridian is negative, east is positive):\n  longitude := -155.8246\n\n  // observer's latitude, in degrees  (*south of the equator is negative, north is positive):\n  latitude := 20.0046\n\n  // observaer's elevation above mean sea level, in meteres:\n  elevation := 4207.0\n\n  // specify the twilight to be defined as a set number of degrees *below* the horizon (e.g, civil twilight is designated as being 6 degrees below horizon):\n  degreesBelowHorizon := -6.0\n\n  twilight, location, err := dusk.GetLocalTwilight(datetime, longitude, latitude, elevation, degreesBelowHorizon)\n}\n```\n\nThere are three wrapper functions which allow for an easy calculation of civil, nautical and astronomical twilight.\n\n### Get Civil Twilight\n\nFor civil twilight, the degreesBelowHorizon for the Sun needs to be -6°.\n\n```go\ntwilight, location, err := dusk.GetLocalCivilTwilight(datetime, longitude, latitude, elevation)\n```\n\n### Get Nautical Twilight\n\nFor nautical twilight, the degreesBelowHorizon for the Sun needs to be -12°.\n\n```go\ntwilight, location, err := dusk.GetLocalNauticalTwilight(datetime, longitude, latitude, elevation)\n```\n\n### Get Astronomical Twilight\n\nFor astronomical twilight, the degreesBelowHorizon for the Sun needs to be -18°.\n\n```go\ntwilight, location, err := dusk.GetLocalAstronomicalTwilight(datetime, longitude, latitude, elevation)\n```\n\n### Get Moon Position\n\nTo calculate the rise and set of the moon, it is neccessary to calculate the equatorial position of the moon at zero HH:mm:ss, e.g., midnight, for the +/-1 day for the day you want to calculate for, e.g., d-1, d and d+1. \n\nThis library supplies the following function to calculate the equatorial position of the moon (in degrees):\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"time\"\n\n  \"github.com/observerly/dusk/pkg/dusk\"\n)\n\nfunc main() {\n  // datetime of observation:\n  datetime := time.Date(2022, 2, 17, 14, 55, 0, 0, time.UTC)\n\n  eq := dusk.GetLunarEquatorialPosition(datetime)\n\t\n  fmt.Printf(\"The Moon is at the following equatorial coordinate:\\n\")\n  fmt.Printf(\"Right Ascension: %e°\\n\", eq.ra)\n  fmt.Printf(\"Declination: %e°\\n\", eq.dec)\n}\n```\n\n### Get Moon Phase\n\nTo calculate the moon phase, it is neccessary to calculate the ecliptic position of the moon at the datetime required, as well as the knowing some longitude of an observer.\n\nThis library supplies the following function to calculate the phase of the moon:\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"time\"\n\n  \"github.com/observerly/dusk/pkg/dusk\"\n)\n\nfunc main() {\n  // datetime of observation:\n  datetime := time.Date(2022, 2, 17, 14, 55, 0, 0, time.UTC)\n\n  // some longitude, in degrees (*west of the Greenwhich meridian is negative, east is positive):\n  lonmgitude := -155.8246\n\n  // get the ecliptic coordinate of the Moon for the datetime:\n  ec := dusk.GetLunarEclipticPosition(datetime)\n\n  // calculate the phase for the datetime, longitude and ecliptic coordinate:\n  phase := dusk.GetMoonPhase(datetime, longitude, ec)\n}\n```\n\n**N.B.** The equatorial coordinate system is a celestial coordinate system widely used to specify the positions of celestial objects. It may be implemented in spherical or rectangular coordinates, both defined by an origin at the centre of Earth, a fundamental plane consisting of the projection of Earth's equator onto the celestial sphere (forming the celestial equator), a primary direction towards the vernal equinox, and a right-handed convention.\n\n## License\n\nDusk is free software licensed under the GNU General Public License v3.0 (GPL-3.0). See [LICENSE](./LICENSE).\n\nThe binary version of this program uses several open source libraries and components, which come with their own licensing terms. See below for an overview, and [LICENSE](./LICENSE) for details.\n\n| Library attribution                                                   | License type |\n|-----------------------------------------------------------------------|--------------|\n| [zsefvlol/timezonemapper](https://github.com/zsefvlol/timezonemapper) | MIT License  |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobserverly%2Fdusk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobserverly%2Fdusk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobserverly%2Fdusk/lists"}