pub struct PgTimeZone { /* private fields */ }Expand description
A time zone as PostgreSQL’s TimeZone setting reads it, equal to another when SHOW timezone
names both alike.
use sql_values::{PgTimeZone, TimeZoneError};
assert_eq!(PgTimeZone::parse("europe/rome").unwrap().name(), "Europe/Rome");
// A number is hours east of UTC, a POSIX specification hours west of it.
assert_eq!(PgTimeZone::parse("+02").unwrap().name(), "<+02>-02");
assert_eq!(PgTimeZone::parse("utc+2").unwrap().name(), "UTC+2");
assert_eq!(PgTimeZone::parse("+168"), Err(TimeZoneError::OffsetOutOfRange));
assert_eq!(PgTimeZone::parse("CEST"), Err(TimeZoneError::InvalidValue));Implementations§
Source§impl PgTimeZone
impl PgTimeZone
Sourcepub fn parse(setting: &str) -> Result<Self, TimeZoneError>
pub fn parse(setting: &str) -> Result<Self, TimeZoneError>
PostgreSQL 18’s check_timezone, reading an interval '...', else a number of hours east of UTC
as C’s strtod reads it, else a name pg_tzset loads, GMT, an IANA name in jiff’s
bundled database or a POSIX specification, refused when its offset at 2000-01-01 has
seconds.
§Errors
The TimeZoneError PostgreSQL raises.
use sql_values::PgTimeZone;
let name = |setting| PgTimeZone::parse(setting).map(|zone| zone.to_string());
assert_eq!(name("2.5").unwrap(), "<+02:30>-02:30");
assert_eq!(name("interval '-01:00'").unwrap(), "<-01>+01");
assert_eq!(name("est5edt").unwrap(), "EST5EDT");
assert_eq!(name("xxx3yyy").unwrap(), "XXX3YYY");Trait Implementations§
Source§impl Clone for PgTimeZone
impl Clone for PgTimeZone
Source§impl Debug for PgTimeZone
impl Debug for PgTimeZone
Source§impl Display for PgTimeZone
impl Display for PgTimeZone
impl Eq for PgTimeZone
Source§impl Hash for PgTimeZone
impl Hash for PgTimeZone
Auto Trait Implementations§
impl Forget for PgTimeZone
impl Freeze for PgTimeZone
impl RefUnwindSafe for PgTimeZone
impl Send for PgTimeZone
impl Sync for PgTimeZone
impl Unpin for PgTimeZone
impl UnsafeUnpin for PgTimeZone
impl UnwindSafe for PgTimeZone
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