Skip to main content

Crate astrotime

Crate astrotime 

Source
Expand description

astrotime

Astrotime is a rust library for dealing with time for scientific and astronomical purposes on the surface of the Earth, or for satellites of the Earth. It is not sufficient for space travel or for solar system objects.

Here is an example of getting the current time:

let now = std::time::SystemTime::now();
let now: Instant = TryFrom::try_from(now).unwrap();
let date: DateTime<Gregorian, Utc> = now.into();
println!("{}", date);

How many seconds have elasped since the UNIX epoch, until New Years 2026? This will yield 1767225628 seconds. Unixtime for that moment was 1767225600 because it ignores the leap seconds that also passed.

let now: DateTime<Gregorian, Utc> = DateTime::new(2026, 1, 1, 0, 0, 0, 0).unwrap();
let n: Instant = now.into();
let d: Duration = n - Epoch::Unix.as_instant();
println!("{} seconds", d.seconds_part());

Structs§

DateTime
A calendar date and time, with attosecond precision, representing the time elapsed since the start of the Common Era in a traditional way according to a particular time Standard.
Duration
Duration is an interval of time
Gregorian
Instant
An Instant is a precise moment in time.
Julian
Tai
International Atomic Time (TAI)
Tcg
Geocentric Coordinate Time (TCG)
Tt
Terrestrial Time (TT)
Utc
Universal Coordinated Time (UTC)

Enums§

Epoch
A reference for a well known Instant in time, used for offsetting events from.
Error
Error type for the crate

Constants§

ATTOS_PER_SEC_F64
ATTOS_PER_SEC_I64
ATTOS_PER_SEC_U64

Traits§

Calendar
This specifies traditional Calendar settings that use the traditional 12 months and have leap years. This is implemented for Gregorian and Julian. It does not handle more esoteric calendars.
Standard
A standard of time

Functions§

leap_instants
This returns the Instants directly after leap seconds.
leap_seconds_elapsed_at
This counts how many leap seconds have elapsed at a given instant.