Time related types (and conversions) for scientific and astronomical usage.

Related tags

Utilities astrotime
Overview

astrotime

Time related types (and conversions) for scientific and astronomical usage.

This library is lightweight and high performance.

Features

The following features are currently available:

  • Handles times covering the entire duration of the universe.
  • Handles times to attosecond precision
  • Allows you to work with Calendar dates and times, either Gregorian or Julian
  • Allows you to work with Julian Day values
  • Converts between time standards (e.g. UTC, TAI, TT, TCG, TCB)
    • Einsteinean reference frames are accounted for with the Tcg (TCG is for geocentric satellites) and Tcb (TCB is for barycentric solar system objects) time standards.
    • Leap seconds are accounted for in conversions to and from UTC (but the list of leap seconds is currently compiled in and may go out of date).
  • Supplies precise instants for well known Epochs such as 1900.0, J1900.0, the Unixtime epoch, Y2K, etc.
  • Optional serde serialization (enable feature 'serde')

Goals

The following are NOT available currently:

  • Ability to update leapseconds from the IETF source online.
  • Handling of civil time issues such as
    • Time zones
    • Daylight Savings Time
    • AM/PM versus 24-hour time
  • Provides (possibly lossy) conversions for types in the 'chrono' and 'time' crates, including rust std SystemTime.
  • Add GPS time and LORAN-C (easy)
  • Add Sidereal time
  • impl ApproxEq from the float_cmp trait for Duration, Instant, and DateTime

One Duration type

Duration represents an interval of time.

Durations can handle lengths of time about 40 times as long as the age of the universe, and have attosecond (10^-18) precision.

Negative values are supported.

DateTime and Instant

There are two types that represent an instant or moment in time.

The first type is a DateTime , which allows easy creation and manipulation of dates using Calendars such as Gregorian or Julian, and which may flexibly represent different time standards (such as Utc, Tai, Tt, Tcg and Tcb). This type intnerally stores the year, month, day, hour, minute, second and attosecond in a packed format. It is 128 bits in size. A DateTime can have a minimum and maximum year within an i32. Thus it does not span the same duration of time that a Duration does.

The second type is an Instant with an opaque implementation, also 128 bits in size. Instants can be subtracted to get a Duration, and a Duration can be added to or subtracted from an Instant to get a different Instant. Instants can span the full duration of time that Duration supports. Instants can convert to and from DateTimes of varying Calendar and Stanadard parameters providing automatic conversion between said Calendars and Standards. Instants can also be converted to and from Julian Days.

Epochs

Well known points in time are provided such as the start of the JulianPeriod, or the start of the JulianCalendar, J1900_0, Unix (the start of UNIXTIME), Y2k, etc.

FAQ

Why attoseconds? Why not just nanoseconds?

I don't have a personal use for such precision, but the data types were 96 bits with nanoseconds, and since computers these days tend to be 64-bit, it seemed that half a word was being wasted. So I extended the fractional seconds part to handle attoseconds.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

You might also like...
Lapce vue plugin, support vue (SFC) syntax highlight, autocomplate,types check
Lapce vue plugin, support vue (SFC) syntax highlight, autocomplate,types check

Lapce Plugin for Vue (based volar) Preview Usage Required: Lapce version must be greater than 2.0, and you can use Lapce nightly version. click here t

serde support for http crate types Request, Response, Uri, StatusCode, HeaderMap

serde extensions for the http crate types Allows serializing and deserializing the following types from http: Response Request HeaderMap StatusCode Ur

Check Have I Been Pwned and see if it's time for you to change passwords.

checkpwn Check Have I Been Pwned and see if it's time for you to change passwords. Getting started Install: cargo install checkpwn Update: cargo inst

Simple and efficient time representation in Rust.

timens-rs Simple and efficient timestamp representation. The main objective being interoperability with OCaml Core_kernel.Time_ns. A significant part

This article is about the unsound api which I found in owning_ref. Owning_ref is a library that has 11 million all-time downloads and 60 reverse dependencies.

Unsoundness in owning_ref This article is about the unsound api which I found in owning_ref. Owning_ref is a library that has 11 million all-time down

Estimate the amount of time spent working on a Git repository

jikyuu (時給) A tool to estimate the amount of time spent working on a Git repository. It is a direct port of git-hours, written in Node.js, because the

Lightweight compile-time UUID parser.

compiled-uuid Anywhere you're building Uuids from a string literal, you should use uuid. Motivation If you want to use a fixed Uuid throughout your pr

Measure the execution time of an application

Execution Timer Drag an executable file on the binary or enter the path as an argument to measure the execution time of the program. Building cargo bu

A real-time event-oriented data-hub

Redcar A real-time event-oriented data-hub, inspired by the data hub. It is: Universal: the front end uses gRPC to provide services. Fast: benchmarked

Comments
  • Conversion to/from UTC near leap seconds

    Conversion to/from UTC near leap seconds

    Currently, we are changing standards between Instants, not between DateTimes. But Instant's cannot differentate a leap second (:60) in UTC, while DateTimes can. As a result, mappnig an instant inside of a leap second to another standard and back will not result in the same Instant.

    We have to rearchitect. Instants are the obviously useful place to convert TCB and TCG to and from TT. But they are impossible for UTC to TAI and back. So I'm going to move the conversions to the DateTimes, and those functions will use Instants (or similar) internally where useful.

    I've had a few false starts, and work has gotten in the way, but this is coming.

    bug 
    opened by mikedilger 0
Owner
Michael Dilger
Anyone who puts reCaptcha on their website has lost me and a billion other bots as potential customers.
Michael Dilger
Astronomical algorithms in Rust

astro-rust Contents API Docs About Usage Contributing References About astro-rust is a library of advanced astronomical algorithms for the Rust progra

Saurav Sachidanand 213 Jan 7, 2023
My bot Roseline for AGTH hooks and VN related stuff

Roseline Web interface My IRC Bot to store AGTH hooks. Commands ping - Obviously send you back pong. vn <title> - Search VN by title. hook <title> - G

Douman 37 Nov 16, 2022
A shared document application akin to Google Docs. Example usage of wasm-peers library.

Live Document Proof of concept application showcasing the usability of wasm-peers crate for easy and costless peer-2-peer WebRTC communication. It's a

null 6 Sep 19, 2022
Github mirror of codeberg repo. Monitor live bandwidth usage/ network speed on PC. Native version also available for Android, separately.

Netspeed Monitor Netspeed is a cross-platform desktop application that shows the live upload speed, download speed and day's usage as an overlay. Feat

Vishnu N K 16 May 3, 2023
A lean, minimal, and stable set of types for color interoperation between crates in Rust.

This library provides a lean, minimal, and stable set of types for color interoperation between crates in Rust. Its goal is to serve the same function that mint provides for (linear algebra) math types.

Gray Olson 16 Sep 21, 2022
A lending iterator trait based on generic associated types and higher-rank trait bounds

A lending iterator trait based on higher-rank trait bounds (HRTBs) A lending iterator is an iterator which lends mutable borrows to the items it retur

Sebastiano Vigna 6 Oct 23, 2023
A framework for iterating over collections of types implementing a trait without virtual dispatch

zero_v Zero_V is an experiment in defining behavior over collections of objects implementing some trait without dynamic polymorphism.

null 13 Jul 28, 2022
Utilities to gather data out of roms. Written in Rust. It (should) support all types.

snesutilities Utilities to gather data out of roms. Written in Rust. It (should) support all types. How Have a look at main.rs: use snesutilities::Sne

Layle | Luca 5 Oct 12, 2022
This crate allows you to safely initialize Dynamically Sized Types (DST) using only safe Rust.

This crate allows you to safely initialize Dynamically Sized Types (DST) using only safe Rust.

Christofer Nolander 11 Dec 22, 2022
Showcase for pathological compile times when using knuffel / chumsky / VERY LARGE types

netherquote Showcase for pathological compile times when using knuffel / chumsky / VERY LARGE types. How to reproduce The rust toolchain version is pi

Amos Wenger 7 Jan 1, 2023