Struct repr::adt::datetime::ParsedDateTime [−][src]
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
Compute an Interval from an ParsedDateTime.
Errors
- If any component overflows a parameter (i.e. i64).
Adds the appropriate values from self’s ParsedDateTime to months
,
seconds
, and nanos
. 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).
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.
Compute a chrono::NaiveDate from an ParsedDateTime.
Errors
- If hour, minute, or second (both
unit
andfraction
) overflowu32
.
pub 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.
Builds a ParsedDateTime from a TIMESTAMP string (value
).
Arguments
value
is a SQL-formatted TIMESTAMP string.
pub 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.
Retrieve any value that we parsed out of the literal string for the
field
.
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for ParsedDateTime
impl Send for ParsedDateTime
impl Sync for ParsedDateTime
impl Unpin for ParsedDateTime
impl UnwindSafe for ParsedDateTime
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more