pub struct Date {
days: i32,
}
Expand description
A Postgres-compatible Date. Additionally clamp valid dates for the range that chrono supports to allow for safe string operations. Infinite dates are not yet supported.
Fields§
§days: i32
Number of days from the postgres epoch (2000-01-01).
Implementations§
source§impl Date
impl Date
pub const UNIX_EPOCH_TO_PG_EPOCH: i32 = 10_957i32
const CE_EPOCH_TO_PG_EPOCH: i32 = 730_120i32
pub const LOW_DAYS: i32 = -2_451_545i32
sourcepub const HIGH_DAYS: i32 = 95_015_279i32
pub const HIGH_DAYS: i32 = 95_015_279i32
Largest date support by Materialize. Although Postgres can go up to 5874897-12-31, chrono is limited to December 31, 262142, which we mirror here so we can use chrono’s formatting methods and have guaranteed safe conversions.
sourcepub fn from_pg_epoch(days: i32) -> Result<Date, DateError>
pub fn from_pg_epoch(days: i32) -> Result<Date, DateError>
Constructs a new Date
as the days since the postgres epoch
(2000-01-01).
sourcepub fn from_unix_epoch(unix_days: i32) -> Result<Date, DateError>
pub fn from_unix_epoch(unix_days: i32) -> Result<Date, DateError>
Constructs a new Date
as the days since the Unix epoch.
sourcepub fn pg_epoch_days(&self) -> i32
pub fn pg_epoch_days(&self) -> i32
Returns the number of days since the postgres epoch.
sourcepub fn is_finite(&self) -> bool
pub fn is_finite(&self) -> bool
Returns whether this is the infinity or -infinity date.
Currently we do not support these, so this function is a light protection against if they are added for functions that will produce incorrect results for these values.
sourcepub fn unix_epoch_days(&self) -> i32
pub fn unix_epoch_days(&self) -> i32
Returns the number of days since the Unix epoch.
Trait Implementations§
source§impl<'a> AsColumnType for Date
impl<'a> AsColumnType for Date
source§fn as_column_type() -> ColumnType
fn as_column_type() -> ColumnType
source§impl<'a, E> DatumType<'a, E> for Date
impl<'a, E> DatumType<'a, E> for Date
source§impl<'de> Deserialize<'de> for Date
impl<'de> Deserialize<'de> for Date
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Ord for Date
impl Ord for Date
source§impl PartialOrd for Date
impl PartialOrd for Date
source§impl RustType<ProtoDate> for Date
impl RustType<ProtoDate> for Date
source§fn into_proto(&self) -> ProtoDate
fn into_proto(&self) -> ProtoDate
Self
into a Proto
value.source§fn from_proto(proto: ProtoDate) -> Result<Self, TryFromProtoError>
fn from_proto(proto: ProtoDate) -> Result<Self, TryFromProtoError>
source§fn into_proto_owned(self) -> Proto
fn into_proto_owned(self) -> Proto
Self::into_proto
that types can
optionally implement, otherwise, the default implementation
delegates to Self::into_proto
.impl Copy for Date
impl Eq for Date
impl StructuralPartialEq for Date
Auto Trait Implementations§
impl Freeze for Date
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnwindSafe for Date
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> PreferredContainer for T
impl<T> PreferredContainer for T
source§impl<T> ProgressEventTimestamp for T
impl<T> ProgressEventTimestamp for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign
, for types that do not implement AddAssign
.