Crates.io | suncalc |
lib.rs | suncalc |
version | 0.4.0 |
source | src |
created_at | 2021-10-23 13:51:44.576581 |
updated_at | 2021-10-29 07:47:20.494951 |
description | Calculate the position of the sun and sunlight phases. |
homepage | https://github.com/tmladek/rust-sun |
repository | https://github.com/tmladek/rust-sun |
max_upload_size | |
id | 469884 |
size | 18,858 |
A rust port of the JS library suncalc, forked from the sun crate.
Features
Add the following to your Cargo.toml
[dependencies]
suncalc = "0.3"
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);
}