2 stable releases

1.0.1 Jun 21, 2023
1.0.0 Dec 15, 2018

#121 in Date and time

Download history 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 2038/week @ 2024-09-29 2152/week @ 2024-10-06 2397/week @ 2024-10-13 3165/week @ 2024-10-20 3638/week @ 2024-10-27 1808/week @ 2024-11-03

11,059 downloads per month
Used in 6 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