2 unstable releases

Uses old Rust 2015

0.2.0 Jul 25, 2015
0.1.0 Jul 16, 2015

#17 in #calculating

Download history 181/week @ 2023-11-19 211/week @ 2023-11-26 161/week @ 2023-12-03 151/week @ 2023-12-10 126/week @ 2023-12-17 28/week @ 2023-12-24 110/week @ 2023-12-31 151/week @ 2024-01-07 223/week @ 2024-01-14 227/week @ 2024-01-21 241/week @ 2024-01-28 248/week @ 2024-02-04 259/week @ 2024-02-11 194/week @ 2024-02-18 177/week @ 2024-02-25 255/week @ 2024-03-03

944 downloads per month
Used in 2 crates

MIT license

5KB
91 lines

sun

A rust port of the JS library suncalc.

Build Status

Install

Add the following to your Cargo.toml

[dependencies]
sun = "0.2"

Usage

extern crate sun;

pub fn main() {
  let unixtime = 1362441600000;
  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);
}

lib.rs:

The sun crate is a library for calculating the position of the sun. It is a port of the JavaScript library suncalc.

Example

extern crate sun;

pub fn main() {
  let unixtime = 1362441600000;
  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);
}

No runtime deps