pub struct TimeWithTimeZone(/* private fields */);Expand description
A safe wrapper around Postgres TIME WITH TIME ZONE type, backed by a pg_sys::TimeTzADT integer value.
Implementations§
Source§impl TimeWithTimeZone
impl TimeWithTimeZone
Sourcepub fn new(
hour: u8,
minute: u8,
second: f64,
) -> Result<TimeWithTimeZone, DateTimeConversionError>
pub fn new( hour: u8, minute: u8, second: f64, ) -> Result<TimeWithTimeZone, DateTimeConversionError>
Construct a new TimeWithTimeZone 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(hour: u8, minute: u8, second: f64) -> TimeWithTimeZone
pub fn new_unchecked(hour: u8, minute: u8, second: f64) -> TimeWithTimeZone
Construct a new TimeWithTimeZone 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>(
hour: u8,
minute: u8,
second: f64,
timezone: Tz,
) -> Result<TimeWithTimeZone, DateTimeConversionError>
pub fn with_timezone<Tz>( hour: u8, minute: u8, second: f64, timezone: Tz, ) -> Result<TimeWithTimeZone, DateTimeConversionError>
Construct a new TimeWithTimeZone 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 with_timezone_offset(
hour: u8,
minute: u8,
second: f64,
timezone_offset: Interval,
) -> Result<TimeWithTimeZone, DateTimeConversionError>
pub fn with_timezone_offset( hour: u8, minute: u8, second: f64, timezone_offset: Interval, ) -> Result<TimeWithTimeZone, DateTimeConversionError>
Construct a new TimeWithTimeZone from its constituent parts at a specific time zone Interval
§Errors
Returns a DateTimeConversionError if any part is outside the bounds for that part
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 timezone_offset(&self) -> i32
pub fn timezone_offset(&self) -> i32
Extract the timezone, measured in seconds past GMT
Sourcepub fn timezone_hour(&self) -> i32
pub fn timezone_hour(&self) -> i32
Extract the timezone_hour, measured in hours past GMT
Sourcepub fn timezone_minute(&self) -> i32
pub fn timezone_minute(&self) -> i32
Extract the timezone_minute, measured in hours past GMT
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 to_utc(&self) -> Time
pub fn to_utc(&self) -> Time
Shift this TimeWithTimeZone to UTC
Sourcepub fn at_timezone<Tz>(
&self,
timezone: Tz,
) -> Result<TimeWithTimeZone, DateTimeConversionError>
pub fn at_timezone<Tz>( &self, timezone: Tz, ) -> Result<TimeWithTimeZone, DateTimeConversionError>
Shift the TimeWithTimeZone 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
Sourcepub fn into_inner(self) -> TimeTzADT
pub fn into_inner(self) -> TimeTzADT
Return the backing pg_sys::TimeTzADT value.
Trait Implementations§
Source§impl Add<Date> for TimeWithTimeZone
impl Add<Date> for TimeWithTimeZone
Source§impl Add<Interval> for TimeWithTimeZone
impl Add<Interval> for TimeWithTimeZone
Source§impl Add<TimeWithTimeZone> for Date
impl Add<TimeWithTimeZone> for Date
Source§type Output = TimestampWithTimeZone
type Output = TimestampWithTimeZone
+ operator.Source§fn add(self, rhs: TimeWithTimeZone) -> <Date as Add<TimeWithTimeZone>>::Output
fn add(self, rhs: TimeWithTimeZone) -> <Date as Add<TimeWithTimeZone>>::Output
+ operation. Read moreSource§impl Add<TimeWithTimeZone> for Interval
impl Add<TimeWithTimeZone> for Interval
Source§type Output = TimeWithTimeZone
type Output = TimeWithTimeZone
+ operator.Source§fn add(
self,
rhs: TimeWithTimeZone,
) -> <Interval as Add<TimeWithTimeZone>>::Output
fn add( self, rhs: TimeWithTimeZone, ) -> <Interval as Add<TimeWithTimeZone>>::Output
+ operation. Read moreSource§impl Clone for TimeWithTimeZone
impl Clone for TimeWithTimeZone
Source§fn clone(&self) -> TimeWithTimeZone
fn clone(&self) -> TimeWithTimeZone
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TimeWithTimeZone
impl Debug for TimeWithTimeZone
Source§impl<'de> Deserialize<'de> for TimeWithTimeZone
impl<'de> Deserialize<'de> for TimeWithTimeZone
Source§fn deserialize<D>(
deserializer: D,
) -> Result<TimeWithTimeZone, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<TimeWithTimeZone, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for TimeWithTimeZone
impl Display for TimeWithTimeZone
Source§impl From<Time> for TimeWithTimeZone
impl From<Time> for TimeWithTimeZone
Source§fn from(t: Time) -> TimeWithTimeZone
fn from(t: Time) -> TimeWithTimeZone
Source§impl From<TimeTzADT> for TimeWithTimeZone
Create a TimeWithTimeZone from a pg_sys::TimeTzADT
impl From<TimeTzADT> for TimeWithTimeZone
Create a TimeWithTimeZone from a pg_sys::TimeTzADT
This impl currently allows creating a TimeWithTimeZone that cannot be constructed by SQL,
such as at the time 37:42 in the time zone UTC+25:00, which may yield logic bugs if used.
Source§fn from(value: TimeTzADT) -> TimeWithTimeZone
fn from(value: TimeTzADT) -> TimeWithTimeZone
Source§impl From<TimeWithTimeZone> for Time
impl From<TimeWithTimeZone> for Time
Source§fn from(value: TimeWithTimeZone) -> Time
fn from(value: TimeWithTimeZone) -> 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 FromDatum for TimeWithTimeZone
impl FromDatum for TimeWithTimeZone
Source§unsafe fn from_polymorphic_datum(
datum: Datum,
is_null: bool,
_typoid: Oid,
) -> Option<TimeWithTimeZone>
unsafe fn from_polymorphic_datum( datum: Datum, is_null: bool, _typoid: Oid, ) -> Option<TimeWithTimeZone>
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 TimeWithTimeZone
impl FromStr for TimeWithTimeZone
Source§fn from_str(
s: &str,
) -> Result<TimeWithTimeZone, <TimeWithTimeZone as FromStr>::Err>
fn from_str( s: &str, ) -> Result<TimeWithTimeZone, <TimeWithTimeZone as FromStr>::Err>
Create this type from a string.
Source§type Err = DateTimeConversionError
type Err = DateTimeConversionError
Source§impl HasExtractableParts for TimeWithTimeZone
impl HasExtractableParts for TimeWithTimeZone
const EXTRACT_FUNCTION: unsafe fn(*mut FunctionCallInfoBaseData) -> Datum = {pgrx::pg_sys::extract_timetz 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 TimeWithTimeZone
impl Hash for TimeWithTimeZone
Source§impl IntoDatum for TimeWithTimeZone
impl IntoDatum for TimeWithTimeZone
Source§impl Ord for TimeWithTimeZone
impl Ord for TimeWithTimeZone
Source§fn cmp(&self, other: &TimeWithTimeZone) -> Ordering
fn cmp(&self, other: &TimeWithTimeZone) -> 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 TimeWithTimeZone
impl PartialEq for TimeWithTimeZone
Source§impl PartialOrd for TimeWithTimeZone
impl PartialOrd for TimeWithTimeZone
Source§impl Serialize for TimeWithTimeZone
impl Serialize for TimeWithTimeZone
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 TimeWithTimeZone in ISO form, compatible with most JSON parsers
Source§impl SqlTranslatable for TimeWithTimeZone
impl SqlTranslatable for TimeWithTimeZone
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 TimeWithTimeZone
impl Sub<Interval> for TimeWithTimeZone
Source§impl ToIsoString for TimeWithTimeZone
impl ToIsoString for TimeWithTimeZone
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>
impl Copy for TimeWithTimeZone
impl Eq for TimeWithTimeZone
Auto Trait Implementations§
impl Freeze for TimeWithTimeZone
impl RefUnwindSafe for TimeWithTimeZone
impl Send for TimeWithTimeZone
impl Sync for TimeWithTimeZone
impl Unpin for TimeWithTimeZone
impl UnwindSafe for TimeWithTimeZone
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.