pub struct EpochDays(/* private fields */);
Expand description

A date represented as the number of days since the unix epoch 1970-01-01.

Implementations§

source§

impl EpochDays

source

pub fn new(epoch_days: i32) -> Self

source

pub fn days(&self) -> i32

source

pub fn from_ymd(year: i32, month: i32, day: i32) -> Self

Convert a date to the number of days since the unix epoch 1970-01-01. See https://github.com/ThreeTen/threetenbp/blob/master/src/main/java/org/threeten/bp/LocalDate.java#L1634

source

pub fn to_ymd(&self) -> (i32, i32, i32)

Convert the number of days since the unix epoch into a (year, month, day) tuple. See https://github.com/ThreeTen/threetenbp/blob/master/src/main/java/org/threeten/bp/LocalDate.java#L281 The resulting month and day values are 1-based.

source

pub fn from_timestamp_millis(ts: i64) -> Self

source

pub fn from_timestamp_millis_float(ts: f64) -> Self

source

pub fn to_timestamp_millis(&self) -> i64

source

pub fn to_timestamp_millis_float(&self) -> f64

source

pub fn add_months(&self, months: i32) -> Self

Adds the given number of months to epoch_days. If the day would be out of range for the resulting month then the date will be clamped to the end of the month.

For example: 2022-01-31 + 1month => 2022-02-28

source

pub fn add_years(&self, years: i32) -> Self

Adds the given number of years to epoch_days. If the day would be out of range for the resulting month then the date will be clamped to the end of the month.

For example: 2020-02-29 + 1year => 2021-02-28

source

pub fn diff_months(&self, other: EpochDays) -> i32

source

pub fn diff_years(&self, other: EpochDays) -> i32

source

pub fn date_trunc_month(&self) -> Self

source

pub fn date_trunc_year(&self) -> Self

source

pub fn date_trunc_quarter(&self) -> Self

source

pub fn extract_year(&self) -> i32

source

pub fn extract_month(&self) -> i32

source

pub fn extract_quarter(&self) -> i32

source

pub fn extract_day_of_month(&self) -> i32

Trait Implementations§

source§

impl Clone for EpochDays

source§

fn clone(&self) -> EpochDays

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for EpochDays

source§

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

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

impl From<EpochDays> for PackedTimestamp

source§

fn from(epoch_days: EpochDays) -> Self

Converts to this type from the input type.
source§

impl PartialEq for EpochDays

source§

fn eq(&self, other: &EpochDays) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for EpochDays

source§

impl Eq for EpochDays

source§

impl StructuralEq for EpochDays

source§

impl StructuralPartialEq for EpochDays

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.