https://github.com/nathan-osman/rust-sunrise
Crate for calculating sunrise / sunset times
https://github.com/nathan-osman/rust-sunrise
astronomy calendar rust sunrise sunset
Last synced: 3 months ago
JSON representation
Crate for calculating sunrise / sunset times
- Host: GitHub
- URL: https://github.com/nathan-osman/rust-sunrise
- Owner: nathan-osman
- License: mit
- Created: 2018-12-12T03:50:08.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2025-05-12T07:48:25.000Z (5 months ago)
- Last Synced: 2025-06-26T18:04:52.507Z (4 months ago)
- Topics: astronomy, calendar, rust, sunrise, sunset
- Language: Rust
- Size: 65.4 KB
- Stars: 18
- Watchers: 3
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## sunrise
[][license]
[][crate]
[][docs]This crate provides a function for calculating sunrise and sunset times using [this method](https://en.wikipedia.org/wiki/Sunrise_equation#Complete_calculation_on_Earth).
To work in a *no-std* environment disable the default features and enable the `libm` feature.
### Usage
In order to perform the calculation, you'll need to provide the following:
- the date for which you wish to calculate the times
- the latitude and longitude of the locationBegin by adding this crate to `Cargo.toml`:
```toml
[dependencies]
sunrise = "1.2"
```You can use the `SolarDay` struct to perform computation of an event at a
particular place and time:```rust
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));
```[crate]: https://crates.io/crates/sunrise "crates.io"
[docs]: https://docs.rs/sunrise "Documentation"
[license]: http://opensource.org/licenses/MIT "MIT License"