sun 0.3.1

Calculate the position of the sun.
Documentation
  • Coverage
  • 28.57%
    6 out of 21 items documented2 out of 6 items with examples
  • Size
  • Source code size: 13.19 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 650.85 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • flosse/rust-sun
    50 9 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • flosse

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}");
}