pub struct TimestampWithTimeZone(/* private fields */);Expand description
A safe wrapper around Postgres TIMESTAMP WITH TIME ZONE type, backed by a pg_sys::Timestamp integer value.
Implementations§
Source§impl TimestampWithTimeZone
impl TimestampWithTimeZone
Sourcepub fn new(
year: i32,
month: u8,
day: u8,
hour: u8,
minute: u8,
second: f64,
) -> Result<TimestampWithTimeZone, DateTimeConversionError>
pub fn new( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: f64, ) -> Result<TimestampWithTimeZone, DateTimeConversionError>
Construct a new TimestampWithTimeZone from its constituent parts.
§Notes
This function uses Postgres’ “current time zone”
§Errors
Returns a DateTimeConversionError if any part is outside the bounds for that part
Sourcepub fn new_unchecked(
year: isize,
month: u8,
day: u8,
hour: u8,
minute: u8,
second: f64,
) -> TimestampWithTimeZone
pub fn new_unchecked( year: isize, month: u8, day: u8, hour: u8, minute: u8, second: f64, ) -> TimestampWithTimeZone
Construct a new TimestampWithTimeZone from its constituent parts.
Elides the overhead of trapping errors for out-of-bounds parts
§Notes
This function uses Postgres’ “current time zone”
§Panics
This function panics if any part is out-of-bounds
Sourcepub fn with_timezone<Tz>(
year: i32,
month: u8,
day: u8,
hour: u8,
minute: u8,
second: f64,
timezone: Tz,
) -> Result<TimestampWithTimeZone, DateTimeConversionError>
pub fn with_timezone<Tz>( year: i32, month: u8, day: u8, hour: u8, minute: u8, second: f64, timezone: Tz, ) -> Result<TimestampWithTimeZone, DateTimeConversionError>
Construct a new TimestampWithTimeZone from its constituent parts at a specific time zone
§Errors
Returns a DateTimeConversionError if any part is outside the bounds for that part
Sourcepub fn positive_infinity() -> TimestampWithTimeZone
pub fn positive_infinity() -> TimestampWithTimeZone
Construct a new TimestampWithTimeZone representing positive infinity
Sourcepub fn negative_infinity() -> TimestampWithTimeZone
pub fn negative_infinity() -> TimestampWithTimeZone
Construct a new TimestampWithTimeZone representing negative infinity
Sourcepub fn is_infinity(&self) -> bool
pub fn is_infinity(&self) -> bool
Does this TimestampWithTimeZone represent positive infinity?
Sourcepub fn is_neg_infinity(&self) -> bool
pub fn is_neg_infinity(&self) -> bool
Does this TimestampWithTimeZone represent negative infinity?
Sourcepub fn microseconds(&self) -> u32
pub fn microseconds(&self) -> u32
Return the microseconds part. This is not the time counted in microseconds, but the
fractional seconds
Sourcepub fn to_hms_micro(&self) -> (u8, u8, u8, u32)
pub fn to_hms_micro(&self) -> (u8, u8, u8, u32)
Return the hour, minute, second, and microseconds as a Rust tuple
Sourcepub fn at_timezone<Tz>(
&self,
timezone: Tz,
) -> Result<Timestamp, DateTimeConversionError>
pub fn at_timezone<Tz>( &self, timezone: Tz, ) -> Result<Timestamp, DateTimeConversionError>
Shift the TimestampWithTimeZone to the specified time zone
§Errors
Returns a DateTimeConversionError if the specified time zone is invalid or if for some
other reason the underlying time cannot be represented in the specified time zone
pub fn is_finite(&self) -> bool
Sourcepub fn truncate(self, units: DateTimeParts) -> TimestampWithTimeZone
pub fn truncate(self, units: DateTimeParts) -> TimestampWithTimeZone
Truncate TimestampWithTimeZone to specified units
Sourcepub fn truncate_with_time_zone<Tz>(
self,
units: DateTimeParts,
zone: Tz,
) -> TimestampWithTimeZone
pub fn truncate_with_time_zone<Tz>( self, units: DateTimeParts, zone: Tz, ) -> TimestampWithTimeZone
Truncate TimestampWithTimeZone to specified units in specified time zone
Not available under Postgres v11
Sourcepub fn age(&self, other: &TimestampWithTimeZone) -> Interval
pub fn age(&self, other: &TimestampWithTimeZone) -> Interval
Subtract other from self, producing a “symbolic” result that uses years and months, rather than just days
Sourcepub fn into_inner(self) -> i64
pub fn into_inner(self) -> i64
Return the backing pg_sys::TimestampTz value.
Trait Implementations§
Source§impl Add<Interval> for TimestampWithTimeZone
impl Add<Interval> for TimestampWithTimeZone
Source§impl Add<TimestampWithTimeZone> for Interval
impl Add<TimestampWithTimeZone> for Interval
Source§type Output = TimestampWithTimeZone
type Output = TimestampWithTimeZone
+ operator.Source§fn add(
self,
rhs: TimestampWithTimeZone,
) -> <Interval as Add<TimestampWithTimeZone>>::Output
fn add( self, rhs: TimestampWithTimeZone, ) -> <Interval as Add<TimestampWithTimeZone>>::Output
+ operation. Read moreSource§impl Clone for TimestampWithTimeZone
impl Clone for TimestampWithTimeZone
Source§fn clone(&self) -> TimestampWithTimeZone
fn clone(&self) -> TimestampWithTimeZone
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TimestampWithTimeZone
impl Debug for TimestampWithTimeZone
Source§impl<'de> Deserialize<'de> for TimestampWithTimeZone
impl<'de> Deserialize<'de> for TimestampWithTimeZone
Source§fn deserialize<D>(
deserializer: D,
) -> Result<TimestampWithTimeZone, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<TimestampWithTimeZone, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for TimestampWithTimeZone
impl Display for TimestampWithTimeZone
Source§impl From<Date> for TimestampWithTimeZone
impl From<Date> for TimestampWithTimeZone
Source§fn from(value: Date) -> TimestampWithTimeZone
fn from(value: Date) -> TimestampWithTimeZone
Source§impl From<Timestamp> for TimestampWithTimeZone
impl From<Timestamp> for TimestampWithTimeZone
Source§fn from(value: Timestamp) -> TimestampWithTimeZone
fn from(value: Timestamp) -> TimestampWithTimeZone
Source§impl From<TimestampWithTimeZone> for Date
impl From<TimestampWithTimeZone> for Date
Source§fn from(value: TimestampWithTimeZone) -> Date
fn from(value: TimestampWithTimeZone) -> Date
Source§impl From<TimestampWithTimeZone> for Time
impl From<TimestampWithTimeZone> for Time
Source§fn from(value: TimestampWithTimeZone) -> Time
fn from(value: TimestampWithTimeZone) -> Time
Source§impl From<TimestampWithTimeZone> for TimeWithTimeZone
impl From<TimestampWithTimeZone> for TimeWithTimeZone
Source§fn from(value: TimestampWithTimeZone) -> TimeWithTimeZone
fn from(value: TimestampWithTimeZone) -> TimeWithTimeZone
Source§impl From<TimestampWithTimeZone> for Timestamp
impl From<TimestampWithTimeZone> for Timestamp
Source§fn from(value: TimestampWithTimeZone) -> Timestamp
fn from(value: TimestampWithTimeZone) -> Timestamp
Source§impl FromDatum for TimestampWithTimeZone
impl FromDatum for TimestampWithTimeZone
Source§unsafe fn from_polymorphic_datum(
datum: Datum,
is_null: bool,
_: Oid,
) -> Option<TimestampWithTimeZone>where
TimestampWithTimeZone: Sized,
unsafe fn from_polymorphic_datum(
datum: Datum,
is_null: bool,
_: Oid,
) -> Option<TimestampWithTimeZone>where
TimestampWithTimeZone: Sized,
from_datum for instantiating polymorphic types
which require preserving the dynamic type metadata. Read moreSource§const GET_TYPOID: bool = false
const GET_TYPOID: bool = false
from_datum?Source§unsafe fn from_datum(datum: Datum, is_null: bool) -> Option<Self>where
Self: Sized,
unsafe fn from_datum(datum: Datum, is_null: bool) -> Option<Self>where
Self: Sized,
Source§unsafe fn from_datum_in_memory_context(
memory_context: PgMemoryContexts,
datum: Datum,
is_null: bool,
typoid: Oid,
) -> Option<Self>where
Self: Sized,
unsafe fn from_datum_in_memory_context(
memory_context: PgMemoryContexts,
datum: Datum,
is_null: bool,
typoid: Oid,
) -> Option<Self>where
Self: Sized,
FromDatum::from_datum(...) from within that context. Read moreSource§unsafe fn try_from_datum(
datum: Datum,
is_null: bool,
type_oid: Oid,
) -> Result<Option<Self>, TryFromDatumError>
unsafe fn try_from_datum( datum: Datum, is_null: bool, type_oid: Oid, ) -> Result<Option<Self>, TryFromDatumError>
try_from_datum is a convenience wrapper around FromDatum::from_datum that returns a
a Result around an Option, as a Datum can be null. It’s intended to be used in
situations where the caller needs to know whether the type conversion succeeded or failed. Read moreSource§unsafe fn try_from_datum_in_memory_context(
memory_context: PgMemoryContexts,
datum: Datum,
is_null: bool,
type_oid: Oid,
) -> Result<Option<Self>, TryFromDatumError>
unsafe fn try_from_datum_in_memory_context( memory_context: PgMemoryContexts, datum: Datum, is_null: bool, type_oid: Oid, ) -> Result<Option<Self>, TryFromDatumError>
try_from_datum that switches to the given context to convert from DatumSource§impl FromStr for TimestampWithTimeZone
impl FromStr for TimestampWithTimeZone
Source§fn from_str(
s: &str,
) -> Result<TimestampWithTimeZone, <TimestampWithTimeZone as FromStr>::Err>
fn from_str( s: &str, ) -> Result<TimestampWithTimeZone, <TimestampWithTimeZone as FromStr>::Err>
Create this type from a string.
Source§type Err = DateTimeConversionError
type Err = DateTimeConversionError
Source§impl HasExtractableParts for TimestampWithTimeZone
impl HasExtractableParts for TimestampWithTimeZone
const EXTRACT_FUNCTION: unsafe fn(*mut FunctionCallInfoBaseData) -> Datum = {pgrx::pg_sys::extract_timestamptz as unsafe fn(*mut pgrx::pg_sys::FunctionCallInfoBaseData) -> pgrx::pg_sys::Datum}
Source§fn extract_part(&self, field: DateTimeParts) -> Option<AnyNumeric>
fn extract_part(&self, field: DateTimeParts) -> Option<AnyNumeric>
DateTimeParts part from a date/time-like typeSource§impl Hash for TimestampWithTimeZone
impl Hash for TimestampWithTimeZone
Source§impl IntoDatum for TimestampWithTimeZone
impl IntoDatum for TimestampWithTimeZone
Source§impl Ord for TimestampWithTimeZone
impl Ord for TimestampWithTimeZone
Source§fn cmp(&self, other: &TimestampWithTimeZone) -> Ordering
fn cmp(&self, other: &TimestampWithTimeZone) -> Ordering
Uses the underlying Postgres “_cmp()” function for this type
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for TimestampWithTimeZone
impl PartialEq for TimestampWithTimeZone
Source§impl PartialOrd for TimestampWithTimeZone
impl PartialOrd for TimestampWithTimeZone
Source§impl RangeSubType for TimestampWithTimeZone
for Timestamp With Time Zone/tstzrange
impl RangeSubType for TimestampWithTimeZone
for Timestamp With Time Zone/tstzrange
fn range_type_oid() -> Oid
Source§impl Serialize for TimestampWithTimeZone
impl Serialize for TimestampWithTimeZone
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this TimestampWithTimeZone in ISO form, compatible with most JSON parsers
Source§impl SqlTranslatable for TimestampWithTimeZone
impl SqlTranslatable for TimestampWithTimeZone
fn argument_sql() -> Result<SqlMapping, ArgumentError>
fn return_sql() -> Result<Returns, ReturnsError>
fn type_name() -> &'static str
fn variadic() -> bool
fn optional() -> bool
fn entity() -> FunctionMetadataTypeEntity
Source§impl Sub<Interval> for TimestampWithTimeZone
impl Sub<Interval> for TimestampWithTimeZone
Source§impl Sub for TimestampWithTimeZone
impl Sub for TimestampWithTimeZone
Source§impl ToIsoString for TimestampWithTimeZone
impl ToIsoString for TimestampWithTimeZone
Source§fn to_iso_string(self) -> String
fn to_iso_string(self) -> String
Source§fn to_iso_string_with_timezone<Tz>(
self,
timezone: Tz,
) -> Result<String, DateTimeConversionError>
fn to_iso_string_with_timezone<Tz>( self, timezone: Tz, ) -> Result<String, DateTimeConversionError>
Source§impl<Tz> TryFrom<(Timestamp, Tz)> for TimestampWithTimeZone
Create a TimestampWithTimeZone from an existing Timestamp (which is understood to be
in the “current time zone” and a time zone string.
impl<Tz> TryFrom<(Timestamp, Tz)> for TimestampWithTimeZone
Create a TimestampWithTimeZone from an existing Timestamp (which is understood to be
in the “current time zone” and a time zone string.
Source§type Error = DateTimeConversionError
type Error = DateTimeConversionError
Source§fn try_from(
value: (Timestamp, Tz),
) -> Result<TimestampWithTimeZone, <TimestampWithTimeZone as TryFrom<(Timestamp, Tz)>>::Error>
fn try_from( value: (Timestamp, Tz), ) -> Result<TimestampWithTimeZone, <TimestampWithTimeZone as TryFrom<(Timestamp, Tz)>>::Error>
Source§impl TryFrom<Datum> for TimestampWithTimeZone
impl TryFrom<Datum> for TimestampWithTimeZone
Source§type Error = FromTimeError
type Error = FromTimeError
Source§fn try_from(
datum: Datum,
) -> Result<TimestampWithTimeZone, <TimestampWithTimeZone as TryFrom<Datum>>::Error>
fn try_from( datum: Datum, ) -> Result<TimestampWithTimeZone, <TimestampWithTimeZone as TryFrom<Datum>>::Error>
Source§impl TryFrom<i64> for TimestampWithTimeZone
Fallibly create a [TimestampWithTimeZone] from a Postgres pg_sys::TimestampTz value.
impl TryFrom<i64> for TimestampWithTimeZone
Fallibly create a [TimestampWithTimeZone] from a Postgres pg_sys::TimestampTz value.
Source§type Error = FromTimeError
type Error = FromTimeError
Source§fn try_from(
value: i64,
) -> Result<TimestampWithTimeZone, <TimestampWithTimeZone as TryFrom<i64>>::Error>
fn try_from( value: i64, ) -> Result<TimestampWithTimeZone, <TimestampWithTimeZone as TryFrom<i64>>::Error>
impl Copy for TimestampWithTimeZone
impl Eq for TimestampWithTimeZone
Auto Trait Implementations§
impl Freeze for TimestampWithTimeZone
impl RefUnwindSafe for TimestampWithTimeZone
impl Send for TimestampWithTimeZone
impl Sync for TimestampWithTimeZone
impl Unpin for TimestampWithTimeZone
impl UnwindSafe for TimestampWithTimeZone
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.