suncalc 0.4.0

Calculate the position of the sun and sunlight phases.
Documentation
  • Coverage
  • 23.33%
    7 out of 30 items documented1 out of 9 items with examples
  • Size
  • Source code size: 19.21 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.39 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • tmladek/rust-sun
    1 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tmladek

sun

A rust port of the JS library suncalc, forked from the sun crate.

Features

  • Get sun position at a given time and position
  • Get sun phase times for a given location
  • Moon calculations

Install

Add the following to your Cargo.toml

[dependencies]
suncalc = "0.3"

Usage

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