pub struct Instant { /* private fields */ }Expand description
Time provider suitable for operations involving intervals.
Implementations§
Source§impl Instant
impl Instant
Sourcepub const fn epoch(_secs: u64) -> Result<Self>
pub const fn epoch(_secs: u64) -> Result<Self>
Creates an instance that refers the UNIX epoch (1970-01-01).
secs is the amount of seconds passed since the UNIX epoch. This parameter is only relevant
for few no_std devices that can’t natively provide time measurements, as such, regular users
should simply pass zero.
Sourcepub fn now() -> Self
pub fn now() -> Self
Returns the system time corresponding to “now”. Can have different durations depending on the underlying provider.
Sourcepub fn now_date_time(secs: u64) -> Result<DateTime<Utc>>
pub fn now_date_time(secs: u64) -> Result<DateTime<Utc>>
Returns a new DateTime instance with the current date and time in UTC based on the
UNIX epoch.
secs is the amount of seconds passed since the UNIX epoch. This parameter is only relevant
for few no_std devices that can’t natively provide time measurements, as such, regular users
should simply pass zero.
Sourcepub fn now_timestamp(secs: u64) -> Result<Duration>
pub fn now_timestamp(secs: u64) -> Result<Duration>
Constructor that returns the number of non-leap seconds since the UNIX epoch.
secs is the amount of seconds passed since the UNIX epoch. This parameter is only relevant
for few no_std devices that can’t natively provide time measurements, as such, regular users
should simply pass zero.
Sourcepub fn add(&self, _duration: Duration) -> Result<Self>
pub fn add(&self, _duration: Duration) -> Result<Self>
Returns the addition if the resulting value is within bounds.
Sourcepub fn sub(&self, _duration: Duration) -> Result<Self>
pub fn sub(&self, _duration: Duration) -> Result<Self>
Returns the difference if the resulting value is within bounds.
Sourcepub fn duration_since(&self, _earlier: Self) -> Result<Duration>
pub fn duration_since(&self, _earlier: Self) -> Result<Duration>
Returns the amount of time elapsed from another instant to this one, or an error if that instant is later than this one.
Sourcepub fn elapsed(&self) -> Result<Duration>
pub fn elapsed(&self) -> Result<Duration>
Returns the amount of time elapsed since this instant was created.
Sourcepub fn timestamp(&self, secs: u64) -> Result<Duration>
pub fn timestamp(&self, secs: u64) -> Result<Duration>
Non-constructor method that returns the number of non-leap seconds since the UNIX epoch based on the current instance.
secs is the amount of seconds passed since the UNIX epoch. This parameter is only relevant
for few no_std devices that can’t natively provide time measurements, as such, regular users
should simply pass zero.