pub struct DateTime { /* private fields */ }
Expand description
A representation of a date and time.
Implementations§
Source§impl DateTime
impl DateTime
Sourcepub const fn ymd(year: i16, month: u8, day: u8) -> DateTimeBuilder
pub const fn ymd(year: i16, month: u8, day: u8) -> DateTimeBuilder
Create a new date and time object.
Sourcepub const fn from_timestamp(timestamp: i64, nanos: u32) -> Self
pub const fn from_timestamp(timestamp: i64, nanos: u32) -> Self
Create a new date and time object from the given Unix timestamp.
Sourcepub const fn from_timestamp_millis(millis: i64) -> Self
pub const fn from_timestamp_millis(millis: i64) -> Self
Create a new date and time object from the given Unix timestamp in milliseconds.
Sourcepub const fn from_timestamp_micros(micros: i64) -> Self
pub const fn from_timestamp_micros(micros: i64) -> Self
Create a new date and time object from the given Unix timestamp in microseconds.
Sourcepub const fn from_timestamp_nanos(nanos: i128) -> Self
pub const fn from_timestamp_nanos(nanos: i128) -> Self
Create a new date and time object from the given Unix timestamp in nanoseconds.
Source§impl DateTime
impl DateTime
Sourcepub const fn with_tz(self, tz: TimeZoneRef<'static>) -> Self
pub const fn with_tz(self, tz: TimeZoneRef<'static>) -> Self
Set the time zone to the provided time zone, without adjusting the underlying absolute timestamp.
This method modifies the wall clock time while maintaining the underlying absolute timestamp.
To modify the timestamp instead, use in_tz
.
Sourcepub const fn in_tz(self, tz: TimeZoneRef<'static>) -> Self
pub const fn in_tz(self, tz: TimeZoneRef<'static>) -> Self
Set the timestamp to the same wall clock time in the provided time zone.
This method modifies the underlying timestamp while maintaining the wall clock time.
To maintain the timestamp instead, use with_tz
.
Source§impl DateTime
Accessors
impl DateTime
Accessors
Sourcepub const fn second(&self) -> u8
pub const fn second(&self) -> u8
The second of the minute for this date and time. Range: [0, 60)
Sourcepub const fn nanosecond(&self) -> u32
pub const fn nanosecond(&self) -> u32
The nanosecond of the second for this date and time. Range: [0, 1_000_000_000)
Sourcepub const fn day_of_year(&self) -> u16
pub const fn day_of_year(&self) -> u16
The ordinal day of the year.
Sourcepub const fn as_seconds(&self) -> i64
pub const fn as_seconds(&self) -> i64
The number of seconds since the Unix epoch for this date and time.
Sourcepub const fn as_milliseconds(&self) -> i64
pub const fn as_milliseconds(&self) -> i64
The number of milliseconds since the Unix epoch for this date and time.
Sourcepub const fn as_microseconds(&self) -> i64
pub const fn as_microseconds(&self) -> i64
The number of microseconds since the Unix epoch for this date and time.
Sourcepub const fn as_nanoseconds(&self) -> i128
pub const fn as_nanoseconds(&self) -> i128
The number of nanoseconds since the Unix epoch for this date and time.
Trait Implementations§
Source§impl Add<TimeInterval> for DateTime
impl Add<TimeInterval> for DateTime
Source§impl AddAssign<TimeInterval> for DateTime
impl AddAssign<TimeInterval> for DateTime
Source§fn add_assign(&mut self, rhs: TimeInterval)
fn add_assign(&mut self, rhs: TimeInterval)
+=
operation. Read moreSource§impl<'__expr> AsExpression<Nullable<Timestamp>> for &'__expr DateTime
impl<'__expr> AsExpression<Nullable<Timestamp>> for &'__expr DateTime
Source§fn as_expression(
self,
) -> <Self as AsExpression<Nullable<Timestamp>>>::Expression
fn as_expression( self, ) -> <Self as AsExpression<Nullable<Timestamp>>>::Expression
Source§impl AsExpression<Nullable<Timestamp>> for DateTime
impl AsExpression<Nullable<Timestamp>> for DateTime
Source§fn as_expression(
self,
) -> <Self as AsExpression<Nullable<Timestamp>>>::Expression
fn as_expression( self, ) -> <Self as AsExpression<Nullable<Timestamp>>>::Expression
Source§impl<'__expr> AsExpression<Nullable<Timestamptz>> for &'__expr DateTime
impl<'__expr> AsExpression<Nullable<Timestamptz>> for &'__expr DateTime
Source§type Expression = Bound<Nullable<Timestamptz>, &'__expr DateTime>
type Expression = Bound<Nullable<Timestamptz>, &'__expr DateTime>
Source§fn as_expression(
self,
) -> <Self as AsExpression<Nullable<Timestamptz>>>::Expression
fn as_expression( self, ) -> <Self as AsExpression<Nullable<Timestamptz>>>::Expression
Source§impl AsExpression<Nullable<Timestamptz>> for DateTime
impl AsExpression<Nullable<Timestamptz>> for DateTime
Source§type Expression = Bound<Nullable<Timestamptz>, DateTime>
type Expression = Bound<Nullable<Timestamptz>, DateTime>
Source§fn as_expression(
self,
) -> <Self as AsExpression<Nullable<Timestamptz>>>::Expression
fn as_expression( self, ) -> <Self as AsExpression<Nullable<Timestamptz>>>::Expression
Source§impl<'__expr> AsExpression<Timestamp> for &'__expr DateTime
impl<'__expr> AsExpression<Timestamp> for &'__expr DateTime
Source§type Expression = Bound<Timestamp, &'__expr DateTime>
type Expression = Bound<Timestamp, &'__expr DateTime>
Source§fn as_expression(self) -> <Self as AsExpression<Timestamp>>::Expression
fn as_expression(self) -> <Self as AsExpression<Timestamp>>::Expression
Source§impl AsExpression<Timestamp> for DateTime
impl AsExpression<Timestamp> for DateTime
Source§type Expression = Bound<Timestamp, DateTime>
type Expression = Bound<Timestamp, DateTime>
Source§fn as_expression(self) -> <Self as AsExpression<Timestamp>>::Expression
fn as_expression(self) -> <Self as AsExpression<Timestamp>>::Expression
Source§impl<'__expr> AsExpression<Timestamptz> for &'__expr DateTime
impl<'__expr> AsExpression<Timestamptz> for &'__expr DateTime
Source§type Expression = Bound<Timestamptz, &'__expr DateTime>
type Expression = Bound<Timestamptz, &'__expr DateTime>
Source§fn as_expression(self) -> <Self as AsExpression<Timestamptz>>::Expression
fn as_expression(self) -> <Self as AsExpression<Timestamptz>>::Expression
Source§impl AsExpression<Timestamptz> for DateTime
impl AsExpression<Timestamptz> for DateTime
Source§type Expression = Bound<Timestamptz, DateTime>
type Expression = Bound<Timestamptz, DateTime>
Source§fn as_expression(self) -> <Self as AsExpression<Timestamptz>>::Expression
fn as_expression(self) -> <Self as AsExpression<Timestamptz>>::Expression
Source§impl<'de> Deserialize<'de> for DateTime
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for DateTime
serde
only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl FromSql for DateTime
impl FromSql for DateTime
Source§fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self>
fn column_result(value: ValueRef<'_>) -> FromSqlResult<Self>
Source§impl FromStr for DateTime
impl FromStr for DateTime
Source§type Err = ParseError
type Err = ParseError
Source§impl Ord for DateTime
impl Ord for DateTime
Source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
Source§impl Sub<TimeInterval> for DateTime
impl Sub<TimeInterval> for DateTime
Source§impl SubAssign<TimeInterval> for DateTime
impl SubAssign<TimeInterval> for DateTime
Source§fn sub_assign(&mut self, rhs: TimeInterval)
fn sub_assign(&mut self, rhs: TimeInterval)
-=
operation. Read moreSource§impl ToSql for DateTime
impl ToSql for DateTime
Source§fn to_sql(&self) -> Result<ToSqlOutput<'_>>
fn to_sql(&self) -> Result<ToSqlOutput<'_>>
Source§impl TryFrom<RawDateTime> for DateTime
impl TryFrom<RawDateTime> for DateTime
Source§type Error = ParseError
type Error = ParseError
Source§fn try_from(value: RawDateTime) -> ParseResult<Self>
fn try_from(value: RawDateTime) -> ParseResult<Self>
impl Copy for DateTime
impl Eq for DateTime
Auto Trait Implementations§
impl Freeze for DateTime
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnwindSafe for DateTime
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T, ST, DB> FromSqlRow<ST, DB> for Twhere
T: Queryable<ST, DB>,
ST: SqlTypeOrSelectable,
DB: Backend,
<T as Queryable<ST, DB>>::Row: FromStaticSqlRow<ST, DB>,
impl<T, ST, DB> FromSqlRow<ST, DB> for Twhere
T: Queryable<ST, DB>,
ST: SqlTypeOrSelectable,
DB: Backend,
<T as Queryable<ST, DB>>::Row: FromStaticSqlRow<ST, DB>,
Source§impl<T, ST, DB> FromStaticSqlRow<ST, DB> for T
impl<T, ST, DB> FromStaticSqlRow<ST, DB> for T
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self
to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self
to an expression for Diesel’s query builder. Read more