[−][src]Struct datetimeutils::PostEpochTime
Conceptually this is a thin wrapper for std::time::SystemTime
, but provides
more useful functions. The impl of this struct has functions that allow easily
extracting the year/month/date/etc. for the given point in time. In actual fact
the internal representation of this struct is a Duration
since the unix epoch,
so that error-handling is only required once upon creating the instance, and
not for each attempt at extracting date/time fields.
Methods
impl PostEpochTime
[src]
pub fn from(st: &SystemTime) -> Result<Self, SystemTimeError>
[src]
Create a PostEpochTime
from a SystemTime
. The SystemTime
must be temporally
in the future relative to the unix epoch, or an error will be returned.
pub fn now() -> Result<Self, SystemTimeError>
[src]
Create a PostEpochTime
for the current instant. The current instant must be
in the future relative to the unix epoch, or an error will be returned.
pub fn milliseconds_since_epoch(&self) -> u128
[src]
Returns the number of milliseconds passed since the unix epoch.
pub fn microseconds_since_epoch(&self) -> u128
[src]
Returns the number of microseconds passed since the unix epoch.
pub fn nanoseconds_since_epoch(&self) -> u128
[src]
Returns the number of nanoseconds passed since the unix epoch.
pub fn seconds_since_epoch(&self) -> u64
[src]
Returns the number of complete seconds passed since the unix epoch.
pub fn days_since_epoch(&self) -> u64
[src]
Returns the number of complete days passed since the unix epoch.
pub fn day_of_week(&self) -> Day
[src]
Returns the day of the week that this point in time falls on.
pub fn year(&self) -> u64
[src]
Returns the year (e.g. 2020) this point in time falls on.
pub fn day_of_year(&self) -> u64
[src]
Returns the day of the year for this point in time (1-indexed). A return value of 1 indicates January 1, a value of 2 indicates January 2, and so on. If the year is a leap year the largest returned value would be 366, and for non-leap years it would be 365.
pub fn month(&self) -> Month
[src]
Returns the month this point in time falls on.
pub fn day_of_month(&self) -> u64
[src]
Returns the day of the month for this point in time (1-indexed). A return value of 1 means it falls on the first of the month. The maximum returned value will be 31.
pub fn second_in_day(&self) -> u64
[src]
Returns the second within the day (0-indexed). This will be in the range 0..86399 (inclusive).
pub fn hour(&self) -> u64
[src]
Returns the hour within the day (0-indexed). This will be in the range 0..23 (inclusive).
pub fn second_in_hour(&self) -> u64
[src]
Returns the second within the hour (0-indexed). This will be in the range 0..3599 (inclusive).
pub fn minute(&self) -> u64
[src]
Returns the minute within the hour (0-indexed). This will be in the range 0..59 (inclusive).
pub fn second(&self) -> u64
[src]
Returns the second within the minute (0-indexed). This will be in the range 0..59 (inclusive).
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for PostEpochTime
impl Send for PostEpochTime
impl Sync for PostEpochTime
impl Unpin for PostEpochTime
impl UnwindSafe for PostEpochTime
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> 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>,