Struct mz_repr::adt::datetime::ParsedDateTime
source · pub struct ParsedDateTime {
pub millennium: Option<DateTimeFieldValue>,
pub century: Option<DateTimeFieldValue>,
pub decade: Option<DateTimeFieldValue>,
pub year: Option<DateTimeFieldValue>,
pub month: Option<DateTimeFieldValue>,
pub day: Option<DateTimeFieldValue>,
pub hour: Option<DateTimeFieldValue>,
pub minute: Option<DateTimeFieldValue>,
pub second: Option<DateTimeFieldValue>,
pub millisecond: Option<DateTimeFieldValue>,
pub microsecond: Option<DateTimeFieldValue>,
pub timezone_offset_second: Option<Timezone>,
}
Expand description
All of the fields that can appear in a literal DATE
, TIME
, TIMESTAMP
or INTERVAL
string.
Fields§
§millennium: Option<DateTimeFieldValue>
§century: Option<DateTimeFieldValue>
§decade: Option<DateTimeFieldValue>
§year: Option<DateTimeFieldValue>
§month: Option<DateTimeFieldValue>
§day: Option<DateTimeFieldValue>
§hour: Option<DateTimeFieldValue>
§minute: Option<DateTimeFieldValue>
§second: Option<DateTimeFieldValue>
§millisecond: Option<DateTimeFieldValue>
§microsecond: Option<DateTimeFieldValue>
§timezone_offset_second: Option<Timezone>
Implementations§
source§impl ParsedDateTime
impl ParsedDateTime
sourcepub fn compute_interval(&self) -> Result<Interval, String>
pub fn compute_interval(&self) -> Result<Interval, String>
Compute an Interval from an ParsedDateTime.
§Errors
- If any component overflows a parameter (i.e. i64).
sourcefn add_field(
&self,
d: DateTimeField,
months: &mut i32,
days: &mut i32,
micros: &mut i64,
) -> Result<(), String>
fn add_field( &self, d: DateTimeField, months: &mut i32, days: &mut i32, micros: &mut i64, ) -> Result<(), String>
Adds the appropriate values from self’s ParsedDateTime to months
,
days
, and micros
. These fields are then appropriate to construct
std::time::Duration, once accounting for their sign.
§Errors
- If any component overflows a parameter (i.e. i64).
sourcepub fn compute_date(&self) -> Result<NaiveDate, String>
pub fn compute_date(&self) -> Result<NaiveDate, String>
Compute a chrono::NaiveDate from an ParsedDateTime.
§Errors
- If year, month, or day overflows their respective parameter in chrono::naive::date::NaiveDate::from_ymd_opt.
Note: Postgres does not recognize Year 0, but in order to make arithmetic work as expected, the Year 1 BC in a ParsedDateTime is mapped to the Year 0 in a NaiveDate, and vice-versa.
sourcepub fn compute_time(&self) -> Result<NaiveTime, String>
pub fn compute_time(&self) -> Result<NaiveTime, String>
Compute a chrono::NaiveDate from an ParsedDateTime.
§Errors
- If hour, minute, or second (both
unit
andfraction
) overflowu32
.
sourcepub fn build_parsed_datetime_interval(
value: &str,
leading_time_precision: Option<DateTimeField>,
ambiguous_resolver: DateTimeField,
) -> Result<ParsedDateTime, String>
pub fn build_parsed_datetime_interval( value: &str, leading_time_precision: Option<DateTimeField>, ambiguous_resolver: DateTimeField, ) -> Result<ParsedDateTime, String>
Builds a ParsedDateTime from an interval string (value
).
§Arguments
value
is a PostgreSQL-compatible interval string, e.gINTERVAL 'value'
.leading_time_precision
optionally identifies the leading time component HOUR | MINUTE to disambiguate {}:{} formatted intervalsambiguous_resolver
identifies the DateTimeField of the final part if it’s ambiguous, e.g. inINTERVAL '1' MONTH
‘1’ is ambiguous as its DateTimeField, but MONTH resolves the ambiguity.
sourcepub fn build_parsed_datetime_timestamp(
value: &str,
) -> Result<ParsedDateTime, String>
pub fn build_parsed_datetime_timestamp( value: &str, ) -> Result<ParsedDateTime, String>
Builds a ParsedDateTime from a TIMESTAMP string (value
).
§Arguments
value
is a SQL-formatted TIMESTAMP string.
sourcepub fn build_parsed_datetime_time(value: &str) -> Result<ParsedDateTime, String>
pub fn build_parsed_datetime_time(value: &str) -> Result<ParsedDateTime, String>
Builds a ParsedDateTime from a TIME string (value
).
§Arguments
value
is a SQL-formatted TIME string.
sourcepub fn write_field_iff_none(
&mut self,
f: DateTimeField,
u: Option<DateTimeFieldValue>,
) -> Result<(), String>
pub fn write_field_iff_none( &mut self, f: DateTimeField, u: Option<DateTimeFieldValue>, ) -> Result<(), String>
Write to the specified field of a ParsedDateTime iff it is currently set to None; otherwise generate an error to propagate to the user.
fn seconds_has_fraction(&self) -> bool
pub fn check_datelike_bounds(&mut self) -> Result<(), String>
pub fn check_interval_bounds(&self, d: DateTimeField) -> Result<(), String>
pub fn clear_date(&mut self)
sourcefn units_of(&self, field: DateTimeField) -> Option<DateTimeFieldValue>
fn units_of(&self, field: DateTimeField) -> Option<DateTimeFieldValue>
Retrieve any value that we parsed out of the literal string for the
field
.
Trait Implementations§
source§impl Clone for ParsedDateTime
impl Clone for ParsedDateTime
source§fn clone(&self) -> ParsedDateTime
fn clone(&self) -> ParsedDateTime
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ParsedDateTime
impl Debug for ParsedDateTime
source§impl Default for ParsedDateTime
impl Default for ParsedDateTime
source§impl Hash for ParsedDateTime
impl Hash for ParsedDateTime
source§impl PartialEq for ParsedDateTime
impl PartialEq for ParsedDateTime
impl Eq for ParsedDateTime
impl StructuralPartialEq for ParsedDateTime
Auto Trait Implementations§
impl Freeze for ParsedDateTime
impl RefUnwindSafe for ParsedDateTime
impl Send for ParsedDateTime
impl Sync for ParsedDateTime
impl Unpin for ParsedDateTime
impl UnwindSafe for ParsedDateTime
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<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> 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
.