#[non_exhaustive]pub enum DatePart {
Show 16 variants
Quarter,
Year,
YearISO,
Month,
Week,
WeekISO,
Day,
DayOfWeekSunday0,
DayOfWeekMonday0,
DayOfYear,
Hour,
Minute,
Second,
Millisecond,
Microsecond,
Nanosecond,
}Expand description
Valid parts to extract from date/time/timestamp arrays.
See date_part.
Marked as non-exhaustive as may expand to support more types of date parts in the future.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Quarter
Quarter of the year, in range 1..=4
Year
Calendar year
YearISO
ISO year, computed as per ISO 8601
Month
Month in the year, in range 1..=12
Week
week of the year, in range 1..=53, computed as per ISO 8601
WeekISO
ISO week of the year, in range 1..=53
Day
Day of the month, in range 1..=31
DayOfWeekSunday0
Day of the week, in range 0..=6, where Sunday is 0
DayOfWeekMonday0
Day of the week, in range 0..=6, where Monday is 0
DayOfYear
Day of year, in range 1..=366
Hour
Hour of the day, in range 0..=23
Minute
Minute of the hour, in range 0..=59
Second
Second of the minute, in range 0..=59
Millisecond
Millisecond of the second
Microsecond
Microsecond of the second
Nanosecond
Nanosecond of the second
Trait Implementations§
Source§impl FromStr for DatePart
Parses a string into a DatePart.
impl FromStr for DatePart
Parses a string into a DatePart.
Matching is case-insensitive. The accepted names follow PostgreSQL’s
EXTRACT / date_part conventions (see
https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT)
and are aligned with the alias set accepted by arrow-cast’s
IntervalUnit::from_str (plurals, short forms like y, mon, ms,
us) so the two parsers round-trip on the names they share.
Names that do not map one-to-one onto a DatePart variant are
intentionally not recognized:
epoch— a derived computation, not a date part.century,decade,millennium— no matchingDatePartvariant.timezone,timezone_hour,timezone_minute— not modeled byDatePart.isodow— PostgreSQL’sisodowreturns1..=7(Mon=1), but the closest variant (DatePart::DayOfWeekMonday0) returns0..=6. Accepting it here would silently shift the value range; callers that need the PostgreSQL semantic should map the alias themselves and add1to the extracted value.