2 stable releases

1.0.1 Jun 21, 2023
1.0.0 Dec 15, 2018

#114 in Date and time

Download history 1778/week @ 2023-12-16 1143/week @ 2023-12-23 1772/week @ 2023-12-30 3859/week @ 2024-01-06 2371/week @ 2024-01-13 1680/week @ 2024-01-20 1558/week @ 2024-01-27 1461/week @ 2024-02-03 2166/week @ 2024-02-10 1639/week @ 2024-02-17 2236/week @ 2024-02-24 2358/week @ 2024-03-02 1749/week @ 2024-03-09 2223/week @ 2024-03-16 2882/week @ 2024-03-23 2662/week @ 2024-03-30

9,804 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