Struct time::date_time::DateTime

source ·
pub struct DateTime<O: MaybeOffset> {
    pub(crate) date: Date,
    pub(crate) time: Time,
    pub(crate) offset: O::MemoryOffsetType,
}

Fields§

§date: Date§time: Time§offset: O::MemoryOffsetType

Implementations§

source§

impl DateTime<None>

source

pub const MIN: Self = _

source

pub const MAX: Self = _

source§

impl DateTime<Fixed>

source

pub const UNIX_EPOCH: Self = _

source§

impl<O: MaybeOffset> DateTime<O>

source

pub const fn new(date: Date, time: Time) -> Selfwhere O: IsOffsetKindNone,

source

pub const fn from_unix_timestamp(timestamp: i64) -> Result<Self, ComponentRange>where O: HasLogicalOffset,

source

pub const fn from_unix_timestamp_nanos( timestamp: i128 ) -> Result<Self, ComponentRange>where O: HasLogicalOffset,

source

pub fn now_utc() -> DateTime<Fixed>where O: IsOffsetKindFixed,

Available on crate feature std only.
source

pub fn now_local() -> Result<DateTime<Fixed>, IndeterminateOffset>where O: IsOffsetKindFixed,

Available on crate feature local-offset only.
source

pub const fn date(self) -> Date

source

pub const fn time(self) -> Time

source

pub const fn offset(self) -> UtcOffsetwhere O: HasLogicalOffset,

source

pub const fn year(self) -> i32

source

pub const fn month(self) -> Month

source

pub const fn day(self) -> u8

source

pub const fn ordinal(self) -> u16

source

pub const fn iso_week(self) -> u8

source

pub const fn sunday_based_week(self) -> u8

source

pub const fn monday_based_week(self) -> u8

source

pub const fn to_calendar_date(self) -> (i32, Month, u8)

source

pub const fn to_ordinal_date(self) -> (i32, u16)

source

pub const fn to_iso_week_date(self) -> (i32, u8, Weekday)

source

pub const fn weekday(self) -> Weekday

source

pub const fn to_julian_day(self) -> i32

source

pub const fn as_hms(self) -> (u8, u8, u8)

source

pub const fn as_hms_milli(self) -> (u8, u8, u8, u16)

source

pub const fn as_hms_micro(self) -> (u8, u8, u8, u32)

source

pub const fn as_hms_nano(self) -> (u8, u8, u8, u32)

source

pub const fn hour(self) -> u8

source

pub const fn minute(self) -> u8

source

pub const fn second(self) -> u8

source

pub const fn millisecond(self) -> u16

source

pub const fn microsecond(self) -> u32

source

pub const fn nanosecond(self) -> u32

source

pub const fn unix_timestamp(self) -> i64where O: HasLogicalOffset,

source

pub const fn unix_timestamp_nanos(self) -> i128where O: HasLogicalOffset,

source

pub const fn assume_offset(self, offset: UtcOffset) -> DateTime<Fixed>where O: NoLogicalOffset,

source

pub const fn assume_utc(self) -> DateTime<Fixed>where O: NoLogicalOffset,

source

pub const fn to_offset(self, offset: UtcOffset) -> DateTime<Fixed>where O: HasLogicalOffset,

source

pub(crate) const fn to_offset_raw(self, offset: UtcOffset) -> (i32, u16, Time)

Equivalent to .to_offset(UtcOffset::UTC), but returning the year, ordinal, and time. This avoids constructing an invalid Date if the new value is out of range.

source

pub const fn checked_add(self, duration: Duration) -> Option<Self>

source

pub const fn checked_sub(self, duration: Duration) -> Option<Self>

source

pub const fn saturating_add(self, duration: Duration) -> Self

source

pub const fn saturating_sub(self, duration: Duration) -> Self

source

pub const fn replace_time(self, time: Time) -> Self

source

pub const fn replace_date(self, date: Date) -> Self

source

pub const fn replace_date_time(self, date_time: DateTime<None>) -> Selfwhere O: HasLogicalOffset,

source

pub const fn replace_year(self, year: i32) -> Result<Self, ComponentRange>

source

pub const fn replace_month(self, month: Month) -> Result<Self, ComponentRange>

source

pub const fn replace_day(self, day: u8) -> Result<Self, ComponentRange>

source

pub const fn replace_hour(self, hour: u8) -> Result<Self, ComponentRange>

source

pub const fn replace_minute(self, minute: u8) -> Result<Self, ComponentRange>

source

pub const fn replace_second(self, second: u8) -> Result<Self, ComponentRange>

source

pub const fn replace_millisecond( self, millisecond: u16 ) -> Result<Self, ComponentRange>

source

pub const fn replace_microsecond( self, microsecond: u32 ) -> Result<Self, ComponentRange>

source

pub const fn replace_nanosecond( self, nanosecond: u32 ) -> Result<Self, ComponentRange>

source

pub const fn replace_offset(self, offset: UtcOffset) -> DateTime<Fixed>where O: IsOffsetKindFixed,

source

pub fn format_into( self, output: &mut impl Write, format: &impl Formattable + ?Sized ) -> Result<usize, Format>

Available on crate feature formatting only.
source

pub fn format( self, format: &impl Formattable + ?Sized ) -> Result<String, Format>

Available on crate feature formatting only.
source

pub fn parse( input: &str, description: &impl Parsable + ?Sized ) -> Result<Self, Parse>

Available on crate feature parsing only.
source

pub(crate) const fn is_valid_leap_second_stand_in(self) -> bool

Available on crate feature parsing only.

A helper method to check if the OffsetDateTime is a valid representation of a leap second. Leap seconds, when parsed, are represented as the preceding nanosecond. However, leap seconds can only occur as the last second of a month UTC.

source

pub const fn to_hms(self) -> (u8, u8, u8)where O: IsOffsetKindFixed,

👎Deprecated since 0.3.18: use as_hms instead
source

pub const fn to_hms_milli(self) -> (u8, u8, u8, u16)where O: IsOffsetKindFixed,

👎Deprecated since 0.3.18: use as_hms_milli instead
source

pub const fn to_hms_micro(self) -> (u8, u8, u8, u32)where O: IsOffsetKindFixed,

👎Deprecated since 0.3.18: use as_hms_micro instead
source

pub const fn to_hms_nano(self) -> (u8, u8, u8, u32)where O: IsOffsetKindFixed,

👎Deprecated since 0.3.18: use as_hms_nano instead

Trait Implementations§

source§

impl<O: MaybeOffset> Add<Duration> for DateTime<O>

§

type Output = DateTime<O>

The resulting type after applying the + operator.
source§

fn add(self, duration: Duration) -> Self

Performs the + operation. Read more
source§

impl<O: MaybeOffset> Add<Duration> for DateTime<O>

§

type Output = DateTime<O>

The resulting type after applying the + operator.
source§

fn add(self, duration: StdDuration) -> Self::Output

Performs the + operation. Read more
source§

impl<O: MaybeOffset> AddAssign<Duration> for DateTime<O>

source§

fn add_assign(&mut self, rhs: StdDuration)

Performs the += operation. Read more
source§

impl<O: MaybeOffset> AddAssign<Duration> for DateTime<O>

source§

fn add_assign(&mut self, rhs: Duration)

Performs the += operation. Read more
source§

impl<O: MaybeOffset + 'static> Arbitrary for DateTime<O>

Available on crate feature quickcheck only.
source§

fn arbitrary(g: &mut Gen) -> Self

Return an arbitrary value. Read more
source§

fn shrink(&self) -> Box<dyn Iterator<Item = Self>>

Return an iterator of values that are smaller than itself. Read more
source§

impl<O: MaybeOffset> Clone for DateTime<O>

source§

fn clone(&self) -> Self

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<O: MaybeOffset> Debug for DateTime<O>

source§

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

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

impl<O: MaybeOffset> Display for DateTime<O>

source§

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

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

impl<O: MaybeOffset> Eq for DateTime<O>

source§

impl From<DateTime<Fixed>> for SystemTime

Available on crate feature std only.
source§

fn from(datetime: DateTime<Fixed>) -> Self

Converts to this type from the input type.
source§

impl From<SystemTime> for DateTime<Fixed>

Available on crate feature std only.
source§

fn from(system_time: SystemTime) -> Self

Converts to this type from the input type.
source§

impl<O: MaybeOffset> Hash for DateTime<O>

source§

fn hash<H: Hasher>(&self, hasher: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<O: MaybeOffset> Ord for DateTime<O>

source§

fn cmp(&self, rhs: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<DateTime<Fixed>> for SystemTime

Available on crate feature std only.
source§

fn eq(&self, rhs: &DateTime<Fixed>) -> 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<O: MaybeOffset> PartialEq<DateTime<O>> for DateTime<O>

source§

fn eq(&self, rhs: &Self) -> 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 PartialEq<SystemTime> for DateTime<Fixed>

Available on crate feature std only.
source§

fn eq(&self, rhs: &SystemTime) -> 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 PartialOrd<DateTime<Fixed>> for SystemTime

Available on crate feature std only.
source§

fn partial_cmp(&self, other: &DateTime<Fixed>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<O: MaybeOffset> PartialOrd<DateTime<O>> for DateTime<O>

source§

fn partial_cmp(&self, rhs: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd<SystemTime> for DateTime<Fixed>

Available on crate feature std only.
source§

fn partial_cmp(&self, other: &SystemTime) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<DateTime<Fixed>> for SystemTime

Available on crate feature std only.
§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: DateTime<Fixed>) -> Self::Output

Performs the - operation. Read more
source§

impl<O: MaybeOffset> Sub<DateTime<O>> for DateTime<O>

§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<O: MaybeOffset> Sub<Duration> for DateTime<O>

§

type Output = DateTime<O>

The resulting type after applying the - operator.
source§

fn sub(self, duration: Duration) -> Self

Performs the - operation. Read more
source§

impl<O: MaybeOffset> Sub<Duration> for DateTime<O>

§

type Output = DateTime<O>

The resulting type after applying the - operator.
source§

fn sub(self, duration: StdDuration) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<SystemTime> for DateTime<Fixed>

Available on crate feature std only.
§

type Output = Duration

The resulting type after applying the - operator.
source§

fn sub(self, rhs: SystemTime) -> Self::Output

Performs the - operation. Read more
source§

impl<O: MaybeOffset> SubAssign<Duration> for DateTime<O>

source§

fn sub_assign(&mut self, rhs: StdDuration)

Performs the -= operation. Read more
source§

impl<O: MaybeOffset> SubAssign<Duration> for DateTime<O>

source§

fn sub_assign(&mut self, rhs: Duration)

Performs the -= operation. Read more
source§

impl<O: MaybeOffset> TryFrom<Parsed> for DateTime<O>

Available on crate feature parsing only.
§

type Error = TryFromParsed

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

fn try_from(parsed: Parsed) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<O: MaybeOffset> Copy for DateTime<O>

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.