[−][src]Struct humantime::Timestamp
A wrapper for SystemTime that has FromStr
implementation
This is useful if you want to use it somewhere where FromStr
is
expected.
See parse_rfc3339_weak
for the description of the format. The "weak"
format is used as it's more pemissive for human input as this is the
expected use of the type (e.g. command-line parsing).
Example
use std::time::SystemTime; let x: SystemTime; x = "2018-02-16T00:31:37Z".parse::<humantime::Timestamp>().unwrap().into(); assert_eq!(humantime::format_rfc3339(x).to_string(), "2018-02-16T00:31:37Z");
Methods from Deref<Target = SystemTime>
pub const UNIX_EPOCH: SystemTime
[src]
pub fn duration_since(
&self,
earlier: SystemTime
) -> Result<Duration, SystemTimeError>
[src]
&self,
earlier: SystemTime
) -> Result<Duration, SystemTimeError>
Returns the amount of time elapsed from an earlier point in time.
This function may fail because measurements taken earlier are not
guaranteed to always be before later measurements (due to anomalies such
as the system clock being adjusted either forwards or backwards).
Instant
can be used to measure elapsed time without this risk of failure.
If successful, Ok
(
Duration
)
is returned where the duration represents
the amount of time elapsed from the specified measurement to this one.
Returns an Err
if earlier
is later than self
, and the error
contains how far from self
the time is.
pub fn checked_add(&self, duration: Duration) -> Option<SystemTime>
[src]
Returns Some(t)
where t
is the time self + duration
if t
can be represented as
SystemTime
(which means it's inside the bounds of the underlying data structure), None
otherwise.
pub fn checked_sub(&self, duration: Duration) -> Option<SystemTime>
[src]
Returns Some(t)
where t
is the time self - duration
if t
can be represented as
SystemTime
(which means it's inside the bounds of the underlying data structure), None
otherwise.
pub fn get_tup(&self) -> (i64, i64)
[src]
Return a tup (sec, nsec)
Trait Implementations
impl AsRef<SystemTime> for Timestamp
[src]
fn as_ref(&self) -> &SystemTime
[src]
impl Clone for Timestamp
[src]
fn clone(&self) -> Timestamp
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Timestamp
[src]
impl Deref for Timestamp
[src]
impl Display for Timestamp
[src]
impl Eq for Timestamp
[src]
impl From<SystemTime> for Timestamp
[src]
fn from(dur: SystemTime) -> Timestamp
[src]
impl FromStr for Timestamp
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Timestamp, Self::Err>
[src]
impl Into<SystemTime> for Timestamp
[src]
fn into(self) -> SystemTime
[src]
impl PartialEq<Timestamp> for Timestamp
[src]
impl StructuralEq for Timestamp
[src]
impl StructuralPartialEq for Timestamp
[src]
Auto Trait Implementations
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,