| Crates.io | sunrise |
| lib.rs | sunrise |
| version | 2.1.0 |
| created_at | 2018-12-15 08:06:37.646089+00 |
| updated_at | 2025-05-12 07:49:01.997023+00 |
| description | Sunrise and sunset calculator |
| homepage | |
| repository | https://github.com/nathan-osman/rust-sunrise |
| max_upload_size | |
| id | 101994 |
| size | 43,924 |
This crate provides a function for calculating sunrise and sunset times using this method.
To work in a no-std environment disable the default features and enable the libm feature.
In order to perform the calculation, you'll need to provide the following:
Begin by adding this crate to Cargo.toml:
[dependencies]
sunrise = "1.2"
You can use the SolarDay struct to perform computation of an event at a
particular place and time:
use chrono::NaiveDate;
use sunrise::{Coordinates, SolarDay, SolarEvent, DawnType};
// January 1, 2016 in Toronto
let date = NaiveDate::from_ymd_opt(2016, 1, 1).unwrap();
let coord = Coordinates::new(43.6532, -79.3832).unwrap();
let dawn = SolarDay::new(coord, date)
.with_altitude(54.)
.event_time(SolarEvent::Dawn(DawnType::Civil));