Skip to main content

Clock

Struct Clock 

Source
pub struct Clock {
    pub nanos: i64,
    pub offset: i16,
}
Expand description

What a statement answers the datetime value functions with: the instant it is running at and the displacement its session keeps.

It is one reading and not a call to the operating system per row, because ISO 20.27 asks that every datetime value function in one statement answer the same instant. A statement that read the clock twice could have CURRENT_DATE and CURRENT_TIMESTAMP land on two days, and a scan of ten million rows would spend ten million system calls finding that out.

The displacement is minutes east of UTC and never a zone name, for the reason the zoned types carry an offset: a name is a rule that changes when the zone database is updated, and a value that means something different tomorrow is not a value.

Fields§

§nanos: i64

Nanoseconds since 1970-01-01T00:00:00Z.

§offset: i16

Minutes east of UTC.

Implementations§

Source§

impl Clock

Source

pub fn read() -> Clock

The clock read now, in UTC, which is what a statement does once before its first row.

The displacement is nought because a session opens in UTC, which is one of the implementation-defined choices the standard leaves open and is written down as such. A session that has moved its zone stamps this reading with what it moved to (GS15), so the zone rides in beside the instant rather than being read here. A clock before the epoch on a machine whose time is set wrong reads as the epoch rather than refusing, since a statement asking what time it is has no better answer to give and no condition to raise.

Source

pub fn instant(self) -> Temporal

The instant as a zoned datetime, which is the one value the five datetime value functions are cut out of.

Trait Implementations§

Source§

impl Clone for Clock

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 Copy for Clock

Source§

impl Debug for Clock

Source§

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

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

impl Default for Clock

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Clock

Source§

impl PartialEq for Clock

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 Clock

Auto Trait Implementations§

§

impl Forget for Clock

§

impl Freeze for Clock

§

impl Move for Clock

§

impl RefUnwindSafe for Clock

§

impl Send for Clock

§

impl Sync for Clock

§

impl Unpin for Clock

§

impl UnsafeUnpin for Clock

§

impl UnwindSafe for Clock

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