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_644i32
pub const HIGH_DAYS: i32 = 95_015_644i32
Largest date support by Materialize. Although Postgres can go up to 5874897-12-31, chrono is limited to December 31, 262143, 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 DatumToPersist for Date
impl DatumToPersist for Date
§type Cfg = ()
type Cfg = ()
Self::Data
, that is
necessary to derive the columnar schema of this type. E.g. for
ScalarType::Record, this will be the schema of the record.const CFG: Self::Cfg = ()
source§fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)
fn encode(col: &mut <Self::Data as Data>::Mut, datum: Datum<'_>)
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 PartialEq<Date> for Date
impl PartialEq<Date> for Date
source§impl PartialOrd<Date> for Date
impl PartialOrd<Date> for Date
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§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>
impl Copy for Date
impl Eq for Date
impl StructuralEq for Date
impl StructuralPartialEq for Date
Auto Trait Implementations§
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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<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
.