pub struct Instant(/* private fields */);Expand description
An Instant is a precise moment in time according to a particular time Standard.
Internally this is stored as a Duration (which is 128 bits in size) offset from an internally chosen epoch.
This represents the same thing that a DateTime does, but it makes it easier to work
with Durations, avoids the complexity of the Calendar, and spans a much larger time
span, able to handle times from about 20 times as old as the age of the
universe backwards, and the same distance forwards, with attosecond (10^-18) precision.
Implementations§
Source§impl Instant
impl Instant
Sourcepub fn from_julian_day_f64(jd: f64) -> Self
pub fn from_julian_day_f64(jd: f64) -> Self
Create from a Julian Day (low precision)
This is not as precise as from_julian_day_parts(), and much less precise than
from_julian_day_precise()
Sourcepub fn from_julian_day_parts(day: i64, day_fraction: f64) -> Self
pub fn from_julian_day_parts(day: i64, day_fraction: f64) -> Self
Create from a Julian Day (medium precision)
This is more precise than from_julian_day_f64() but not as precise as
from_julian_day_precise()
Sourcepub fn from_julian_day_precise(
day: i64,
seconds: u32,
attoseconds: i64,
) -> Result<Self, Error>
pub fn from_julian_day_precise( day: i64, seconds: u32, attoseconds: i64, ) -> Result<Self, Error>
Create from a Julian Day (maximum precision)
This is more precise than from_julian_day_f64() but not as precise as
from_julian_day_precise()
§Errors
This will throw an Error::RangeError if the seconds are out of
bounds (0 <= seconds < 86_400) or the attoseconds are out of bounds
(0 <= attoseconds < 1_000_000_000_000_000_000)
Sourcepub fn as_julian_day_f64(&self) -> f64
pub fn as_julian_day_f64(&self) -> f64
As Julian day (low precision)
Sourcepub fn as_julian_day_parts(&self) -> (i64, f64)
pub fn as_julian_day_parts(&self) -> (i64, f64)
As Julian day (medium precision)
This returns a day number and a day fraction.
Sourcepub fn as_julian_day_precise(&self) -> (i64, i64, i64)
pub fn as_julian_day_precise(&self) -> (i64, i64, i64)
As Julian day (high precision)
This returns a day number, a second number, and an attoseconds number
Sourcepub fn as_julian_day_formatted(&self) -> String
pub fn as_julian_day_formatted(&self) -> String
As julian day (formatted as a string)