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: i64Nanoseconds since 1970-01-01T00:00:00Z.
offset: i16Minutes east of UTC.
Implementations§
Source§impl Clock
impl Clock
Sourcepub fn read() -> Clock
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.