A Rust library for calculating sun positions

Overview

sun

A rust port of the JS library suncalc.

Build Status Build status

Install

Add the following to your Cargo.toml

[dependencies]
sun = "0.2"

Usage

pub fn main() {
  let unixtime = 1362441600000;
  let lat = 48.0;
  let lon = 9.0;
  let pos = sun::pos(unixtime,lat,lon);
  let az  = pos.azimuth.to_degrees();
  let alt = pos.altitude.to_degrees();
  println!("The position of the sun is {}/{}", az, alt);
}
You might also like...
Stack unwinding library in Rust

Unwinding library in Rust and for Rust This library serves two purposes: Provide a pure Rust alternative to libgcc_eh or libunwind. Provide easier unw

Easy to use Rust i18n library based on code generation

rosetta-i18n rosetta-i18n is an easy-to-use and opinionated Rust internationalization (i18n) library powered by code generation. rosetta_i18n::include

A library for advanced finite element computations in Rust
A library for advanced finite element computations in Rust

A Rust library for building advanced applications with the Finite Element Method (FEM). Although developed with a special emphasis on solid mechanics

Mononym is a library for creating unique type-level names for each value in Rust.

Mononym is a library for creating unique type-level names for each value in Rust.

tiny_id is a Rust library for generating non-sequential, tightly-packed short IDs.

tiny_id tiny_id is a Rust library for generating non-sequential, tightly-packed short IDs. Most other short ID generators just string together random

islam is an Islamic library for Rust.

islam is an Islamic library for Rust. It is a direct port of PyIslam with a slight change in the API part.

A Rust library for managing eBPF programs.

oxidebpf oxidebpf is a permissive licensed Rust library for managing eBPF programs. Motivation The motivation behind oxidebpf is to create a permissiv

A rust library that makes reading and writing memory of the Dolphin emulator easier.

dolphin-memory-rs A crate for reading from and writing to the emulated memory of Dolphin in rust. A lot of internals here are directly based on aldela

Rust library for interacting with the VTube Studio API

vtubestudio-rs A library for interacting with the VTube Studio API. Basic usage This example creates a Client using the provided builder, which: conne

Comments
  • Change unixtime_in_ms type

    Change unixtime_in_ms type

    Hi! Thank you for your crate! Nice to have this kind of calculations in rust! :) I am now putting it into my project :)

    I want to ask about one thing: I think it is unable that unixtime_in_ms could be negative, what do you think? In this case it would be probably better if you change it from i64 to u128. And u128 is because the rust's Duration::as_millis() is returning u128 type. So in this case we don't need to cast...

    Look how I am obtaining the time: https://stackoverflow.com/a/44378174

    opened by manio 2
  • Convert to no-std

    Convert to no-std

    Hey :wave:

    Thanks for your work, I'm glab that I can use your lib. My usage is in a no-std env so I need it to be no-std too. It's a small change that you may want, feel free to merge. (I can turn it into a no-std feature if you want to avoid unecessary deps.)

    opened by Greedeuh 2
  • πŸŒ“ moon functions πŸŒ—

    πŸŒ“ moon functions πŸŒ—

    Hello! I was looking into porting the moon functions from mourner/suncalc. Would you want those in this repo?

    I've done the moon position function so far, and I noticed to you add PI to the azimuth in the rust version. Just curious why; I don't know anything about astronomy math :)

    enhancement 
    opened by laduke 1
Owner
Markus Kohlhase
(flosse = free libre open source software engineering)
Markus Kohlhase
A cross-platform serial port library in Rust.

Introduction serialport-rs is a general-purpose cross-platform serial port library for Rust. It provides a blocking I/O interface and port enumeration

Bryant Mairs 143 Nov 5, 2021
A high level diffing library for rust based on diffs

Similar: A Diffing Library Similar is a dependency free crate for Rust that implements different diffing algorithms and high level interfaces for it.

Armin Ronacher 617 Dec 30, 2022
A reactive DOM library for Rust in WASM

maple A VDOM-less web library with fine-grained reactivity. Getting started The recommended build tool is Trunk. Start by adding maple-core to your Ca

Luke Chu 1.8k Jan 3, 2023
transmute-free Rust library to work with the Arrow format

Arrow2: Transmute-free Arrow This repository contains a Rust library to work with the Arrow format. It is a re-write of the official Arrow crate using

Jorge Leitao 708 Dec 30, 2022
Cross-platform Window library in Rust for Tauri. [WIP]

Cross-platform application window creation library in Rust that supports all major platforms like Windows, macOS, Linux, iOS and Android. Built for you, maintained for Tauri.

Tauri 899 Jan 1, 2023
A library in Rust for theorem proving with Intuitionistic Propositional Logic.

Prop Propositional logic with types in Rust. A library in Rust for theorem proving with Intuitionistic Propositional Logic. Supports theorem proving i

AdvancedResearch 48 Jan 3, 2023
A Rust library for constructing tilings of regular polygons

tiling tiling is a library for constructing tilings of regular polygons and their dual tilings. Resources Documentation Tilings by regular polygons Li

Jonas Michel 29 Sep 30, 2021
miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

miette is a diagnostic library for Rust. It includes a series of traits/protocols that allow you to hook into its error reporting facilities, and even write your own error reports!

Kat MarchΓ‘n 1.2k Jan 1, 2023
Generative arts library in Rust

Generative Generative (WIP) is 2D generational arts creation library written in Rust. Currently it is in nascent stage and is somewhat unstable. Examp

Gaurav Patel 22 May 13, 2022
Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.

Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.

Jerel Unruh 70 Dec 13, 2022