Skip to content

litejs/sun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LiteJS Sun – Coverage Size Buy Me A Tea

Sun position and timing calculations based on NOAA solar equations.

$ npm install @litejs/sun
import { sun } from "@litejs/sun"

let data = sun(59.437, 24.753, "2025-03-20T12:00:00Z")
console.log("Sunrise:", data.rise.time, "Sunset:", data.set.time)
// Sunrise: 2025-03-20T04:22:24.000Z Sunset: 2025-03-20T16:35:43.000Z
console.log("Azimuth:", data.azimuth, "Elevation:", data.el)
// Azimuth: 206.16 Elevation: 28.01

API

sun(lat, lon, time)

Returns an object with the following properties:

Property Description
time Date object for the given time
decl Solar declination (degrees)
dur Daylight duration (minutes)
el Solar elevation with refraction (degrees)
elTrue Solar elevation without refraction (degrees)
eqTime Equation of time (minutes)
hourAngle Solar hour angle (degrees)
azimuth Solar azimuth (degrees, lazy)
dist Distance to sun in AU (lazy)
rightAsc Right ascension (degrees, lazy)
noon Solar noon data (lazy)
rise Sunrise data (lazy)
set Sunset data (lazy)

The noon, rise, and set getters return objects with the same structure, with time refined to the exact event. During polar day or polar night, rise and set find the nearest event, which may be days or months away. Returns null only at extreme latitudes (e.g., the poles) where no sunrise or sunset occurs within a year.

Contributing

Follow Coding Style Guide, run tests npm install; npm test.

Copyright (c) 2025 Lauri Rooden <[email protected]>
MIT License | GitHub repo | npm package | Buy Me A Tea

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published