pub struct PgTimeTz { /* private fields */ }Expand description
A PostgreSQL timetz, a time of day with the offset east of UTC it was written with,
ordered by the instant and then by the offset, as timetz_cmp orders it.
use sql_values::{PgTime, PgTimeTz};
let noon = PgTime::from_hms_micro(12, 0, 0, 0).unwrap();
let rome = PgTimeTz::new(noon, 3_600).unwrap();
assert_eq!(rome.to_string(), "12:00:00+01");
let utc = PgTimeTz::new(PgTime::from_hms_micro(11, 0, 0, 0).unwrap(), 0).unwrap();
// At one instant the offset decides, by PostgreSQL's zone in seconds west of UTC.
assert_ne!(rome, utc);
assert!(rome < utc);Implementations§
Source§impl PgTimeTz
impl PgTimeTz
Sourcepub fn parse(
text: &str,
context: InputContext<'_>,
) -> Result<Self, DateTimeError>
pub fn parse( text: &str, context: InputContext<'_>, ) -> Result<Self, DateTimeError>
PostgreSQL’s timetz_in, reading HH:MM[:SS[.f]] up to 24:00:00 with an offset or a
zone of one fixed offset, and allballs. A time without an offset, or with a zone whose
offset changes, takes the offset of the current date, which this reader does not model.
§Errors
The DateTimeError PostgreSQL raises, or DateTimeError::Unsupported for another
spelling or a time whose offset the current date decides.
use sql_values::{InputContext, PgTimeTz};
let read = |text| PgTimeTz::parse(text, InputContext::new()).map(|t| t.to_string());
assert_eq!(read("12:00:00-05:30").unwrap(), "12:00:00-05:30");
assert_eq!(read("allballs").unwrap(), "00:00:00+00");Trait Implementations§
impl Copy for PgTimeTz
Source§impl<'de> Deserialize<'de> for PgTimeTz
impl<'de> Deserialize<'de> for PgTimeTz
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for PgTimeTz
Source§impl Ord for PgTimeTz
impl Ord for PgTimeTz
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for PgTimeTz
impl PartialOrd for PgTimeTz
impl StructuralPartialEq for PgTimeTz
Auto Trait Implementations§
impl Forget for PgTimeTz
impl Freeze for PgTimeTz
impl RefUnwindSafe for PgTimeTz
impl Send for PgTimeTz
impl Sync for PgTimeTz
impl Unpin for PgTimeTz
impl UnsafeUnpin for PgTimeTz
impl UnwindSafe for PgTimeTz
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
Mutably borrows from an owned value. Read more