2 unstable releases

Uses old Rust 2015

0.2.0 Jul 25, 2015
0.1.0 Jul 16, 2015

#2 in #sun

Download history 556/week @ 2022-10-13 348/week @ 2022-10-20 553/week @ 2022-10-27 669/week @ 2022-11-03 838/week @ 2022-11-10 748/week @ 2022-11-17 380/week @ 2022-11-24 637/week @ 2022-12-01 482/week @ 2022-12-08 360/week @ 2022-12-15 211/week @ 2022-12-22 337/week @ 2022-12-29 493/week @ 2023-01-05 670/week @ 2023-01-12 687/week @ 2023-01-19 738/week @ 2023-01-26

2,693 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