Crates.io | astrotime |
lib.rs | astrotime |
version | 0.1.0 |
source | src |
created_at | 2022-01-18 02:32:12.371626 |
updated_at | 2022-01-18 02:32:12.371626 |
description | Time related types |
homepage | |
repository | https://github.com/mikedilger/astrotime |
max_upload_size | |
id | 515894 |
size | 116,543 |
Time related types (and conversions) for scientific and astronomical usage.
This library is lightweight and high performance.
The following features are currently available:
Tcg
(TCG is for
geocentric satellites) and Tcb
(TCB is for barycentric solar system
objects) time standards.The following are NOT available currently:
Duration
represents an interval of time.
Duration
s 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.
There are two types that represent an instant or moment in time.
The first type is a DateTime<Calendar, Standard>
, 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.
Instant
s 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. Instant
s can convert to and from DateTime
s
of varying Calendar
and Stanadard
parameters providing automatic conversion between said
Calendar
s and Standard
s. Instant
s can also be converted to and from Julian Days.
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.
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.
Licensed under either of
at your option.
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.