2 stable releases

1.0.1 Jun 21, 2023
1.0.0 Dec 15, 2018

#134 in Date and time

Download history 1537/week @ 2024-06-16 2347/week @ 2024-06-23 1306/week @ 2024-06-30 2849/week @ 2024-07-07 3346/week @ 2024-07-14 4114/week @ 2024-07-21 4593/week @ 2024-07-28 6883/week @ 2024-08-04 3955/week @ 2024-08-11 2303/week @ 2024-08-18 1893/week @ 2024-08-25 2184/week @ 2024-09-01 2085/week @ 2024-09-08 2328/week @ 2024-09-15 2325/week @ 2024-09-22 1935/week @ 2024-09-29

8,748 downloads per month
Used in 5 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