No description
Find a file
2025-12-07 22:28:08 +01:00
src Switch to Rust Edition 2024 & Rust 1.90 2025-09-19 00:14:13 +02:00
.gitignore initial commit 2015-07-17 01:20:22 +02:00
Cargo.toml Change repository and homepage URLs 2025-12-07 22:28:08 +01:00
README.md Release v0.3.0 2024-10-18 03:42:30 +02:00

sun

A Rust port of the JS library suncalc.

Crates.io Docs.rs

Install

Add the following to your Cargo.toml

[dependencies]
sun = "0.3"

Usage

pub fn main() {
  let unixtime = 1_362_441_600_000.0;
  let lat = 48.0;
  let lon = 9.0;
  let pos = sun::pos(unixtime,lat,lon);
  let az  = pos.azimuth.to_degrees();
  let alt = pos.altitude.to_degrees();
  println!("The position of the sun is {az}/{alt}");

  let time_ms = sun::time_at_phase(unixtime, sun::SunPhase::Sunrise, lat, lon, 0.0);
  println!("Sunrise is at {time_ms}");
}