Skip to main content

Temporal

Enum Temporal 

Source
pub enum Temporal {
    Date(NaiveDate),
    CivilDate {
        year: i64,
        month: u32,
        day: u32,
    },
    LocalTime(NaiveTime),
    Time {
        time: NaiveTime,
        offset: i32,
    },
    LocalDateTime(NaiveDateTime),
    CivilDateTime {
        year: i64,
        month: u32,
        day: u32,
        time: NaiveTime,
    },
    DateTime {
        utc: NaiveDateTime,
        offset: i32,
        zone: Option<String>,
    },
    Duration {
        months: i64,
        days: i64,
        nanos: i128,
    },
}

Variants§

§

Date(NaiveDate)

§

CivilDate

Out-of-range proleptic date (TCK ±999999999).

Fields

§year: i64
§month: u32
§day: u32
§

LocalTime(NaiveTime)

§

Time

Fields

§offset: i32
§

LocalDateTime(NaiveDateTime)

§

CivilDateTime

Fields

§year: i64
§month: u32
§day: u32
§

DateTime

Fields

§offset: i32
§

Duration

Fields

§months: i64
§days: i64
§nanos: i128

Implementations§

Source§

impl Temporal

Source

pub fn kind_name(&self) -> &'static str

Source

pub fn has_date(&self) -> bool

Whether the value carries a calendar date — the one statement of the capability partition, beside the type. The field policy (field_rules::check_sources), the truncation granularity rule and the part readers all read it, so no consumer keeps its own variant list.

Source

pub fn has_time(&self) -> bool

Whether the value carries a time of day (see Temporal::has_date).

Source

pub fn has_date_and_time(&self) -> bool

Whether the value carries both halves (the datetime source field).

Source

pub fn iso_string(&self) -> String

Source

pub fn full_seconds_string(&self) -> String

The full-precision ISO rendering: Temporal::iso_string with the time-of-day’s seconds always present. The value layer’s temporal rendering policy for every string-producing surface — toString (top-level, nested in a map or accepted list, or through toStringOrNull) and the interpolated-string scalar path — one rendering for one value, however it was built or wherever it is embedded (ADR-0448).

Source

pub fn component(&self, key: &str) -> Result<Value, Error>

One component accessor (d.year, t.offsetMinutes, dur.months). The reference engine rejects a component the value’s kind does not carry, so [component::read] is the whole policy: the reader answers a component its kind carries or the read is a typed error.

Source

pub fn equals(&self, other: &Temporal) -> bool

Cypher = between two values of the same temporal kind (false for unlike kinds). The relation is deliberately not the ordering one:

  • Time — local time and offset, so 12:00+01:00 and 11:00Z (the same instant) are different times, while 12:00Z and 12:00+00:00 are the same.
  • DateTime — local date-time and zone identity, so the two halves of a DST fall-back overlap (02:30+02:00[Europe/Stockholm] and 02:30+01:00[Europe/Stockholm]) are equal even though they are different instants, while [Europe/Stockholm] never equals +01:00 (ZoneId).
Source

pub fn datetime_eq_identity(&self) -> Option<(NaiveDateTime, ZoneId)>

The two components Self::equals compares for a zoned DateTime: its local wall clock and its ZoneId. None for every other temporal kind. This is the = identity only; the property index, uniqueness probe and MERGE key the finer equivalence identity (UTC instant plus zone), so the two halves of a DST fall-back overlap are equal yet separate index entries (LABS-785).

Source

pub fn compare(&self, other: &Temporal) -> Option<Ordering>

Three-valued ordering for <, >, <=, >= (None is the null result of comparing incomparable values):

  • Time — UTC nanos-of-day (not wrapped at midnight, so it can be negative), then the offset, so two times at the same instant still order.
  • DateTime — instant (nanos included), then offset, then a plain offset before a named zone, then the zone name.
  • Duration — not orderable at all; only = is defined for it.
Source

pub fn same_instant(&self, other: &Temporal) -> bool

IS SAME INSTANT (Cypher 25 chronological comparison): the UTC instant for the two zoned kinds — DateTime by its stored UTC half, Time by [utc_time_nanos] — and Self::equals for the non-zoned kinds, whose clock already is the instant. Unlike kinds are false here too; the operator’s mixed-kind null/false policy stays with the caller, this relation only answers for a comparable pair.

Source

pub fn instant_ordering(&self, other: &Temporal) -> Option<Ordering>

IS BEFORE/IS AFTER ordering (Cypher 25): the instant alone for the zoned kinds — Self::compare also ranks equal instants by offset and then zone, which a chronological operator must not — and Self::compare for every other kind (durations stay unordered: None).

Trait Implementations§

Source§

impl Clone for Temporal

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Temporal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Temporal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Temporal

Source§

impl PartialEq for Temporal

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Temporal

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.