/suncalc

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

Primary LanguageJavaScriptBSD 2-Clause "Simplified" LicenseBSD-2-Clause

SunCalc

This is a refactored fork of SunCalc only returning calculated times.

SunCalc is a tiny BSD-licensed JavaScript library for calculating sunlight phases (times for sunrise, sunset, dusk, etc.) created by Vladimir Agafonkin (@mourner).

Most calculations are based on the formulas given in the excellent Astronomy Answers articles about position of the sun and the planets. You can read about different twilight phases calculated by SunCalc in the Twilight article on Wikipedia.

Reference

Sunlight times

SunCalc(/*Date*/ date, /*Number*/ latitude, /*Number*/ longitude)

Returns an object with the following properties

Property Description
sunrise sunrise
sunset sunset
dusk end of dusk twilights
.civil civil twilight
.nautical nautical twilights
.astronomical astronomical twilight (night begins)
dawn beginning of dawn twilights
.civil civil dawn
.nautical nautical dawn
.astronomical astronomical dawn (night ends)
antipodes
.nadir nadir (darkest moment of the night, sun is in the lowest position)
.zenith solar noon (sun is in the highest position)

Changelog

2.0.0

Forked from original, moon positions removed. Output reworked.