Struct arrow_ipc::gen::Schema::Timestamp

source ·
pub struct Timestamp<'a> {
    pub _tab: Table<'a>,
}
Expand description

Timestamp is a 64-bit signed integer representing an elapsed time since a fixed epoch, stored in either of four units: seconds, milliseconds, microseconds or nanoseconds, and is optionally annotated with a timezone.

Timestamp values do not include any leap seconds (in other words, all days are considered 86400 seconds long).

§Timestamps with a non-empty timezone

If a Timestamp column has a non-empty timezone value, its epoch is 1970-01-01 00:00:00 (January 1st 1970, midnight) in the UTC timezone (the Unix epoch), regardless of the Timestamp’s own timezone.

Therefore, timestamp values with a non-empty timezone correspond to physical points in time together with some additional information about how the data was obtained and/or how to display it (the timezone).

For example, the timestamp value 0 with the timezone string “Europe/Paris” corresponds to “January 1st 1970, 00h00” in the UTC timezone, but the application may prefer to display it as “January 1st 1970, 01h00” in the Europe/Paris timezone (which is the same physical point in time).

One consequence is that timestamp values with a non-empty timezone can be compared and ordered directly, since they all share the same well-known point of reference (the Unix epoch).

§Timestamps with an unset / empty timezone

If a Timestamp column has no timezone value, its epoch is 1970-01-01 00:00:00 (January 1st 1970, midnight) in an unknown timezone.

Therefore, timestamp values without a timezone cannot be meaningfully interpreted as physical points in time, but only as calendar / clock indications (“wall clock time”) in an unspecified timezone.

For example, the timestamp value 0 with an empty timezone string corresponds to “January 1st 1970, 00h00” in an unknown timezone: there is not enough information to interpret it as a well-defined physical point in time.

One consequence is that timestamp values without a timezone cannot be reliably compared or ordered, since they may have different points of reference. In particular, it is not possible to interpret an unset or empty timezone as the same as “UTC”.

§Conversion between timezones

If a Timestamp column has a non-empty timezone, changing the timezone to a different non-empty value is a metadata-only operation: the timestamp values need not change as their point of reference remains the same (the Unix epoch).

However, if a Timestamp column has no timezone value, changing it to a non-empty value requires to think about the desired semantics. One possibility is to assume that the original timestamp values are relative to the epoch of the timezone being set; timestamp values should then adjusted to the Unix epoch (for example, changing the timezone from empty to “Europe/Paris” would require converting the timestamp values from “Europe/Paris” to “UTC”, which seems counter-intuitive but is nevertheless correct).

§Guidelines for encoding data from external libraries

Date & time libraries often have multiple different data types for temporal data. In order to ease interoperability between different implementations the Arrow project has some recommendations for encoding these types into a Timestamp column.

An “instant” represents a physical point in time that has no relevant timezone (for example, astronomical data). To encode an instant, use a Timestamp with the timezone string set to “UTC”, and make sure the Timestamp values are relative to the UTC epoch (January 1st 1970, midnight).

A “zoned date-time” represents a physical point in time annotated with an informative timezone (for example, the timezone in which the data was recorded). To encode a zoned date-time, use a Timestamp with the timezone string set to the name of the timezone, and make sure the Timestamp values are relative to the UTC epoch (January 1st 1970, midnight).

(There is some ambiguity between an instant and a zoned date-time with the UTC timezone. Both of these are stored the same in Arrow. Typically, this distinction does not matter. If it does, then an application should use custom metadata or an extension type to distinguish between the two cases.)

An “offset date-time” represents a physical point in time combined with an explicit offset from UTC. To encode an offset date-time, use a Timestamp with the timezone string set to the numeric timezone offset string (e.g. “+03:00”), and make sure the Timestamp values are relative to the UTC epoch (January 1st 1970, midnight).

A “naive date-time” (also called “local date-time” in some libraries) represents a wall clock time combined with a calendar date, but with no indication of how to map this information to a physical point in time. Naive date-times must be handled with care because of this missing information, and also because daylight saving time (DST) may make some values ambiguous or nonexistent. A naive date-time may be stored as a struct with Date and Time fields. However, it may also be encoded into a Timestamp column with an empty timezone. The timestamp values should be computed “as if” the timezone of the date-time values was UTC; for example, the naive date-time “January 1st 1970, 00h00” would be encoded as timestamp value 0.

Fields§

§_tab: Table<'a>

Implementations§

source§

impl<'a> Timestamp<'a>

source

pub const VT_UNIT: VOffsetT = 4u16

source

pub const VT_TIMEZONE: VOffsetT = 6u16

source

pub unsafe fn init_from_table(table: Table<'a>) -> Self

source

pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( _fbb: &'mut_bldr mut FlatBufferBuilder<'bldr>, args: &'args TimestampArgs<'args>, ) -> WIPOffset<Timestamp<'bldr>>

source

pub fn unit(&self) -> TimeUnit

source

pub fn timezone(&self) -> Option<&'a str>

The timezone is an optional string indicating the name of a timezone, one of:

  • As used in the Olson timezone database (the “tz database” or “tzdata”), such as “America/New_York”.
  • An absolute timezone offset of the form “+XX:XX” or “-XX:XX”, such as “+07:30”.

Whether a timezone string is present indicates different semantics about the data (see above).

Trait Implementations§

source§

impl<'a> Clone for Timestamp<'a>

source§

fn clone(&self) -> Timestamp<'a>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Timestamp<'_>

source§

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

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

impl<'a> Follow<'a> for Timestamp<'a>

§

type Inner = Timestamp<'a>

source§

unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner

Safety Read more
source§

impl<'a> PartialEq for Timestamp<'a>

source§

fn eq(&self, other: &Timestamp<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Verifiable for Timestamp<'_>

source§

fn run_verifier( v: &mut Verifier<'_, '_>, pos: usize, ) -> Result<(), InvalidFlatbuffer>

Runs the verifier for this type, assuming its at position pos in the verifier’s buffer. Should not need to be called directly.
source§

impl<'a> Copy for Timestamp<'a>

source§

impl<'a> StructuralPartialEq for Timestamp<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Timestamp<'a>

§

impl<'a> RefUnwindSafe for Timestamp<'a>

§

impl<'a> Send for Timestamp<'a>

§

impl<'a> Sync for Timestamp<'a>

§

impl<'a> Unpin for Timestamp<'a>

§

impl<'a> UnwindSafe for Timestamp<'a>

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

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

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,