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§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<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
.