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<O: MaybeOffset> DateTime<O>
impl<O: MaybeOffset> DateTime<O>
pub const fn new(date: Date, time: Time) -> Selfwhere O: IsOffsetKindNone,
pub const fn from_unix_timestamp(timestamp: i64) -> Result<Self, ComponentRange>where O: HasLogicalOffset,
pub const fn from_unix_timestamp_nanos( timestamp: i128 ) -> Result<Self, ComponentRange>where O: HasLogicalOffset,
pub fn now_utc() -> DateTime<Fixed>where O: IsOffsetKindFixed,
Available on crate feature
std
only.pub fn now_local() -> Result<DateTime<Fixed>, IndeterminateOffset>where O: IsOffsetKindFixed,
Available on crate feature
local-offset
only.pub const fn date(self) -> Date
pub const fn time(self) -> Time
pub const fn offset(self) -> UtcOffsetwhere O: HasLogicalOffset,
pub const fn year(self) -> i32
pub const fn month(self) -> Month
pub const fn day(self) -> u8
pub const fn ordinal(self) -> u16
pub const fn iso_week(self) -> u8
pub const fn sunday_based_week(self) -> u8
pub const fn monday_based_week(self) -> u8
pub const fn to_calendar_date(self) -> (i32, Month, u8)
pub const fn to_ordinal_date(self) -> (i32, u16)
pub const fn to_iso_week_date(self) -> (i32, u8, Weekday)
pub const fn weekday(self) -> Weekday
pub const fn to_julian_day(self) -> i32
pub const fn as_hms(self) -> (u8, u8, u8)
pub const fn as_hms_milli(self) -> (u8, u8, u8, u16)
pub const fn as_hms_micro(self) -> (u8, u8, u8, u32)
pub const fn as_hms_nano(self) -> (u8, u8, u8, u32)
pub const fn hour(self) -> u8
pub const fn minute(self) -> u8
pub const fn second(self) -> u8
pub const fn millisecond(self) -> u16
pub const fn microsecond(self) -> u32
pub const fn nanosecond(self) -> u32
pub const fn unix_timestamp(self) -> i64where O: HasLogicalOffset,
pub const fn unix_timestamp_nanos(self) -> i128where O: HasLogicalOffset,
pub const fn assume_offset(self, offset: UtcOffset) -> DateTime<Fixed>where O: NoLogicalOffset,
pub const fn assume_utc(self) -> DateTime<Fixed>where O: NoLogicalOffset,
pub const fn to_offset(self, offset: UtcOffset) -> DateTime<Fixed>where O: HasLogicalOffset,
sourcepub(crate) const fn to_offset_raw(self, offset: UtcOffset) -> (i32, u16, Time)
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.
pub const fn checked_add(self, duration: Duration) -> Option<Self>
pub const fn checked_sub(self, duration: Duration) -> Option<Self>
pub const fn saturating_add(self, duration: Duration) -> Self
pub const fn saturating_sub(self, duration: Duration) -> Self
pub const fn replace_time(self, time: Time) -> Self
pub const fn replace_date(self, date: Date) -> Self
pub const fn replace_date_time(self, date_time: DateTime<None>) -> Selfwhere O: HasLogicalOffset,
pub const fn replace_year(self, year: i32) -> Result<Self, ComponentRange>
pub const fn replace_month(self, month: Month) -> Result<Self, ComponentRange>
pub const fn replace_day(self, day: u8) -> Result<Self, ComponentRange>
pub const fn replace_hour(self, hour: u8) -> Result<Self, ComponentRange>
pub const fn replace_minute(self, minute: u8) -> Result<Self, ComponentRange>
pub const fn replace_second(self, second: u8) -> Result<Self, ComponentRange>
pub const fn replace_millisecond( self, millisecond: u16 ) -> Result<Self, ComponentRange>
pub const fn replace_microsecond( self, microsecond: u32 ) -> Result<Self, ComponentRange>
pub const fn replace_nanosecond( self, nanosecond: u32 ) -> Result<Self, ComponentRange>
pub const fn replace_offset(self, offset: UtcOffset) -> DateTime<Fixed>where O: IsOffsetKindFixed,
pub fn format_into( self, output: &mut impl Write, format: &impl Formattable + ?Sized ) -> Result<usize, Format>
Available on crate feature
formatting
only.pub fn format( self, format: &impl Formattable + ?Sized ) -> Result<String, Format>
Available on crate feature
formatting
only.pub fn parse( input: &str, description: &impl Parsable + ?Sized ) -> Result<Self, Parse>
Available on crate feature
parsing
only.sourcepub(crate) const fn is_valid_leap_second_stand_in(self) -> bool
Available on crate feature parsing
only.
pub(crate) const fn is_valid_leap_second_stand_in(self) -> bool
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.
pub const fn to_hms(self) -> (u8, u8, u8)where O: IsOffsetKindFixed,
👎Deprecated since 0.3.18: use
as_hms
insteadpub const fn to_hms_milli(self) -> (u8, u8, u8, u16)where O: IsOffsetKindFixed,
👎Deprecated since 0.3.18: use
as_hms_milli
insteadpub const fn to_hms_micro(self) -> (u8, u8, u8, u32)where O: IsOffsetKindFixed,
👎Deprecated since 0.3.18: use
as_hms_micro
insteadpub const fn to_hms_nano(self) -> (u8, u8, u8, u32)where O: IsOffsetKindFixed,
👎Deprecated since 0.3.18: use
as_hms_nano
insteadTrait Implementations§
source§impl<O: MaybeOffset> AddAssign<Duration> for DateTime<O>
impl<O: MaybeOffset> AddAssign<Duration> for DateTime<O>
source§fn add_assign(&mut self, rhs: StdDuration)
fn add_assign(&mut self, rhs: StdDuration)
Performs the
+=
operation. Read moresource§impl<O: MaybeOffset> AddAssign<Duration> for DateTime<O>
impl<O: MaybeOffset> AddAssign<Duration> for DateTime<O>
source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
Performs the
+=
operation. Read moresource§impl<O: MaybeOffset + 'static> Arbitrary for DateTime<O>
Available on crate feature quickcheck
only.
impl<O: MaybeOffset + 'static> Arbitrary for DateTime<O>
Available on crate feature
quickcheck
only.source§impl<O: MaybeOffset> Clone for DateTime<O>
impl<O: MaybeOffset> Clone for DateTime<O>
source§impl<O: MaybeOffset> Debug for DateTime<O>
impl<O: MaybeOffset> Debug for DateTime<O>
source§impl<O: MaybeOffset> Display for DateTime<O>
impl<O: MaybeOffset> Display for DateTime<O>
source§impl<O: MaybeOffset> Eq for DateTime<O>
impl<O: MaybeOffset> Eq for DateTime<O>
fn assert_receiver_is_total_eq(&self)
source§impl From<SystemTime> for DateTime<Fixed>
Available on crate feature std
only.
impl From<SystemTime> for DateTime<Fixed>
Available on crate feature
std
only.source§fn from(system_time: SystemTime) -> Self
fn from(system_time: SystemTime) -> Self
Converts to this type from the input type.
source§impl<O: MaybeOffset> Hash for DateTime<O>
impl<O: MaybeOffset> Hash for DateTime<O>
source§impl<O: MaybeOffset> Ord for DateTime<O>
impl<O: MaybeOffset> Ord for DateTime<O>
source§impl PartialEq<DateTime<Fixed>> for SystemTime
Available on crate feature std
only.
impl PartialEq<DateTime<Fixed>> for SystemTime
Available on crate feature
std
only.source§impl PartialEq<SystemTime> for DateTime<Fixed>
Available on crate feature std
only.
impl PartialEq<SystemTime> for DateTime<Fixed>
Available on crate feature
std
only.source§fn eq(&self, rhs: &SystemTime) -> bool
fn eq(&self, rhs: &SystemTime) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<DateTime<Fixed>> for SystemTime
Available on crate feature std
only.
impl PartialOrd<DateTime<Fixed>> for SystemTime
Available on crate feature
std
only.1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl<O: MaybeOffset> PartialOrd<DateTime<O>> for DateTime<O>
impl<O: MaybeOffset> PartialOrd<DateTime<O>> for DateTime<O>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl PartialOrd<SystemTime> for DateTime<Fixed>
Available on crate feature std
only.
impl PartialOrd<SystemTime> for DateTime<Fixed>
Available on crate feature
std
only.source§fn partial_cmp(&self, other: &SystemTime) -> Option<Ordering>
fn partial_cmp(&self, other: &SystemTime) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl<O: MaybeOffset> SubAssign<Duration> for DateTime<O>
impl<O: MaybeOffset> SubAssign<Duration> for DateTime<O>
source§fn sub_assign(&mut self, rhs: StdDuration)
fn sub_assign(&mut self, rhs: StdDuration)
Performs the
-=
operation. Read moresource§impl<O: MaybeOffset> SubAssign<Duration> for DateTime<O>
impl<O: MaybeOffset> SubAssign<Duration> for DateTime<O>
source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
Performs the
-=
operation. Read moreimpl<O: MaybeOffset> Copy for DateTime<O>
Auto Trait Implementations§
impl<O> RefUnwindSafe for DateTime<O>where <O as MaybeOffset>::MemoryOffsetType: RefUnwindSafe,
impl<O> Send for DateTime<O>where <O as MaybeOffset>::MemoryOffsetType: Send,
impl<O> Sync for DateTime<O>where <O as MaybeOffset>::MemoryOffsetType: Sync,
impl<O> Unpin for DateTime<O>where <O as MaybeOffset>::MemoryOffsetType: Unpin,
impl<O> UnwindSafe for DateTime<O>where <O as MaybeOffset>::MemoryOffsetType: UnwindSafe,
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