Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 780 Bytes

README.md

File metadata and controls

25 lines (18 loc) · 780 Bytes

Build Status

daylight-rust

Very simple Rust library to calculate the moment of sunrise, sunset and twilight times at a given date, latitude and longitude. The used algorithms to calculate the timestamps are based on http://www.sci.fi/~benefon/rscalc.c.

extern crate time;
extern crate daylight;

use time::{at, now};
use daylight::calculate_daylight;

fn main() {
    let lat_apeldoorn = 52.0 + 13.0/60.0;
    let long_apeldoorn = 5.0 + 58.0/60.0;

    let daylight = calculate_daylight(now(), lat_apeldoorn, long_apeldoorn);

    println!("Today the sun sets in Apeldoorn at {}",
        at(daylight.sunset).strftime("%I:%M%p").unwrap());
}