# mourner/suncalc

A tiny JavaScript library for calculating sun/moon positions and phases.

Repository: https://github.com/mourner/suncalc
Canonical: https://ross.abutalabs.com/products/suncalc
Language: JavaScript
License: BSD-2-Clause
License Family: permissive
Last push: 2026-07-11T10:56:17+00:00

## Health v2 (maintenance only)
Score: 94/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 92, release rhythm 92, longevity 100
- inputs: {"age_days": 5487, "days_push": 53, "days_rel": 53, "gap_med": 23, "n_releases_24m": 2}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3463, forks 440 (observed 2026-08-28T04:08:05.728927+00:00)

## What it is
SunCalc is a tiny, dependency-free JavaScript library for calculating sun position, sunlight phases (sunrise, sunset, dusk), moon position, moonrise/moonset times, and lunar phase for any location and time. Its calculations are based on Jean Meeus' Astronomical Algorithms and match the accuracy of timeanddate.com and the U.S. Naval Observatory.

## Use cases
- calculate sunrise and sunset times for a location
- get sun azimuth and altitude for photography planning
- compute moon phase and moonrise times
- determine twilight and dusk times for a given date and coordinates
- add day/night lighting calculations to a web app or game

## When to choose
- you need lightweight, dependency-free sun/moon calculations in JavaScript
- you want accuracy matching timeanddate.com or the U.S. Naval Observatory
- you need both browser and Node.js support with a simple API

## When to avoid
- you need high-precision ephemeris-grade astronomical data
- you need calculations for planets, stars, or other celestial bodies
- you work outside JavaScript

## Facets
- artifact type: library
- maturity: stable
- function: math, sdk
- domain: astronomy, cross-platform
- platform: browser
- tags: sun-position, moon-phase, sunrise-sunset, astronomical-calculations, dependency-free, algorithms, javascript, nodejs

## Member repositories
- mourner/suncalc (main) score 94

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:08:05.728927+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:36:53.683384+00:00, confidence not recorded.
  - readme: https://github.com/mourner/suncalc (fetched 2026-08-28T04:08:05.728927+00:00, sha 88c6854b5aec)
  - registry_npm: https://registry.npmjs.org/suncalc (fetched 2026-08-29T09:31:05.563859+00:00, sha 26c4d68532db)
- Data as of 2026-08-30T08:39:29.467469+00:00.
