tmladek / rust-sun

A Rust library for calculating sun positions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sun

A rust port of the JS library suncalc, forked from the sun crate.

Features

  • Get sun position at a given time and position
  • Get sun phase times for a given location
  • Moon calculations

Install

Add the following to your Cargo.toml

[dependencies]
suncalc = "0.3"

Usage

pub fn main() {
  let unixtime = suncalc::Timestamp(1362441600000);
  let lat = 48.0;
  let lon = 9.0;
  let pos = suncalc::get_position(unixtime,lat,lon);
  let az  = pos.azimuth.to_degrees();
  let alt = pos.altitude.to_degrees();
  println!("The position of the sun is {}/{}", az, alt);
}

About

A Rust library for calculating sun positions


Languages

Language:Rust 98.2%Language:Nix 1.8%