Crates.io | sunrise-next |
lib.rs | sunrise-next |
version | 1.2.3 |
source | src |
created_at | 2023-06-17 11:10:16.926626 |
updated_at | 2023-06-24 20:21:45.362013 |
description | Sunrise and sunset calculator |
homepage | |
repository | https://github.com/nathan-osman/rust-sunrise |
max_upload_size | |
id | 892833 |
size | 38,071 |
This is a fork of nathan-osman's crate to test new features.
This crate provides a function for calculating sunrise and sunset times using this method.
You can enable the no-std feature if you need it to work in such a context, it will rely on libm
instead.
In order to perform the calculation, you'll need to provide the following:
Begin by adding this crate to Cargo.toml
:
[dependencies]
sunrise-next = "1.2"
You can use
the sunrise_sunset
function to perform the calculation:
// Calculate times for January 1, 2016 in Toronto
let (sunrise, sunset) = sunrise::sunrise_sunset(43.6532, -79.3832, 2016, 1, 1);
If you need more refined control, you can use the SolarDay
struct:
use sunrise::{sunrise_sunset, SolarDay, SolarEvent, DawnType};
let dawn = SolarDay::new(43.6532, -79.3832, 2016, 1, 1)
.with_altitude(54.)
.event_time(SolarEvent::Dawn(DawnType::Civil));