Struct Epoch

Source
pub struct Epoch { /* private fields */ }
Expand description

A struct that provides conversions to/from epochs/date/time.

Implementations§

Source§

impl Epoch

Source

pub const fn new(datetime: OffsetDateTime) -> Epoch

Instantiates a new Epoch

Source

pub fn from_parts(parts: DateTimeParts) -> Result<Epoch>

Creates a new Epoch from DateTimeParts

Source

pub fn from_epoch_s(epoch_s: i64) -> Result<Epoch>

Creates an epoch from seconds

Source

pub fn from_epoch_ms(epoch_ms: i128) -> Result<Epoch>

Creates an epoch from milliseconds

Source

pub fn from_epoch_us(epoch_us: i128) -> Result<Epoch>

Creates an epoch from microseconds

Source

pub fn from_epoch_ns(epoch_ns: i128) -> Result<Epoch>

Creates an epoch from nanoseconds

Source

pub fn epoch_s(&self) -> i64

Returns the epoch as seconds

Source

pub fn epoch_ms(&self) -> Result<i128>

Returns the epoch as milliseconds

Source

pub fn epoch_us(&self) -> Result<i128>

Returns the epoch as microseconds

Source

pub fn epoch_ns(&self) -> i128

Returns the epoch as nanoseconds

Source

pub fn fmt(&self) -> String

Formats the epoch as a date/time

Trait Implementations§

Source§

impl Debug for Epoch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Epoch

Source§

fn default() -> Self

Returns the current epoch

Source§

impl TryFrom<DateTimeParts> for Epoch

Source§

fn try_from(parts: DateTimeParts) -> Result<Self>

Attempts to convert DateTimeParts into an Epoch

Source§

type Error = EpochError

The type returned in the event of a conversion error.

Auto Trait Implementations§

§

impl Freeze for Epoch

§

impl RefUnwindSafe for Epoch

§

impl Send for Epoch

§

impl Sync for Epoch

§

impl Unpin for Epoch

§

impl UnwindSafe for Epoch

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.