2 stable releases

1.0.1 Jun 21, 2023
1.0.0 Dec 15, 2018

#124 in Date and time

Download history 3239/week @ 2024-01-10 2181/week @ 2024-01-17 1649/week @ 2024-01-24 1339/week @ 2024-01-31 1932/week @ 2024-02-07 1892/week @ 2024-02-14 2200/week @ 2024-02-21 2168/week @ 2024-02-28 2176/week @ 2024-03-06 1555/week @ 2024-03-13 2866/week @ 2024-03-20 3082/week @ 2024-03-27 2782/week @ 2024-04-03 2218/week @ 2024-04-10 3644/week @ 2024-04-17 2896/week @ 2024-04-24

12,342 downloads per month
Used in 4 crates

MIT license

23KB
206 lines

sunrise

This crate provides a function for calculating sunrise and sunset times using this method.

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 location

Begin by adding this crate to Cargo.toml:

[dependencies]
sunrise = "1.0.0"

Next, add a declaration for the crate:

extern crate sunrise;

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,
);

Dependencies

~1MB
~18K SLoC