pub struct UnixTimeStamp(/* private fields */);
Expand description
Default value is 1970-01-01 00:00:00 UTC.
UnixTimeStamp stores number of seconds elapsed since 1970-01-01 00:00:00 UTC
as u32
.
Implementations§
Source§impl UnixTimeStamp
impl UnixTimeStamp
Sourcepub fn new(system_time: SystemTime) -> Result<Self, UnixTimeStampError>
pub fn new(system_time: SystemTime) -> Result<Self, UnixTimeStampError>
Create new unix timestamp from system_time
.
Sourcepub const fn unix_epoch() -> Self
pub const fn unix_epoch() -> Self
Return unix epoch, same as UnixTimeStamp::default
Sourcepub fn from_raw(elapsed: u32) -> Option<Self>
pub fn from_raw(elapsed: u32) -> Option<Self>
Return None
if std::time::SystemTime
cannot hold the timestamp.
Sourcepub fn into_raw(self) -> u32
pub fn into_raw(self) -> u32
Into u32
which is used to internally store the timestamp in seconds.
Sourcepub fn as_duration(self) -> Duration
pub fn as_duration(self) -> Duration
Convert timestamp to Duration
.
Sourcepub fn as_system_time(self) -> SystemTime
pub fn as_system_time(self) -> SystemTime
Convert timestamp back to SystemTime
.
Trait Implementations§
Source§impl Clone for UnixTimeStamp
impl Clone for UnixTimeStamp
Source§fn clone(&self) -> UnixTimeStamp
fn clone(&self) -> UnixTimeStamp
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for UnixTimeStamp
impl Debug for UnixTimeStamp
Source§impl Default for UnixTimeStamp
impl Default for UnixTimeStamp
Source§fn default() -> UnixTimeStamp
fn default() -> UnixTimeStamp
Returns the “default value” for a type. Read more
Source§impl Hash for UnixTimeStamp
impl Hash for UnixTimeStamp
Source§impl PartialEq for UnixTimeStamp
impl PartialEq for UnixTimeStamp
impl Copy for UnixTimeStamp
impl Eq for UnixTimeStamp
impl StructuralPartialEq for UnixTimeStamp
Auto Trait Implementations§
impl Freeze for UnixTimeStamp
impl RefUnwindSafe for UnixTimeStamp
impl Send for UnixTimeStamp
impl Sync for UnixTimeStamp
impl Unpin for UnixTimeStamp
impl UnwindSafe for UnixTimeStamp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)