pub struct GmtOffset(_);
Expand description
The GMT offset in seconds for a timezone
Implementations
sourceimpl GmtOffset
impl GmtOffset
sourcepub fn try_from_offset_seconds(seconds: i32) -> Result<GmtOffset, TimeZoneError>
pub fn try_from_offset_seconds(seconds: i32) -> Result<GmtOffset, TimeZoneError>
Attempt to create a GmtOffset
from a seconds input. It returns an error when the seconds
overflows or underflows.
sourcepub unsafe fn from_offset_seconds_unchecked(seconds: i32) -> GmtOffset
pub unsafe fn from_offset_seconds_unchecked(seconds: i32) -> GmtOffset
Create a GmtOffset
from a seconds input without checking bounds.
Safety
The seconds must be a valid value as returned by Self::offset_seconds
.
sourcepub fn offset_seconds(self) -> i32
pub fn offset_seconds(self) -> i32
Returns the raw offset value in seconds.
sourcepub fn is_positive(self) -> bool
pub fn is_positive(self) -> bool
Returns true
if the GmtOffset
is positive, otherwise false
.
sourcepub fn has_minutes(self) -> bool
pub fn has_minutes(self) -> bool
Returns true
if the GmtOffset
has non-zero minutes, otherwise false
.
sourcepub fn has_seconds(self) -> bool
pub fn has_seconds(self) -> bool
Returns true
if the GmtOffset
has non-zero seconds, otherwise false
.
Trait Implementations
sourceimpl FromStr for GmtOffset
impl FromStr for GmtOffset
sourcefn from_str(input: &str) -> Result<GmtOffset, <GmtOffset as FromStr>::Err>
fn from_str(input: &str) -> Result<GmtOffset, <GmtOffset as FromStr>::Err>
Parse a GmtOffset
from a string.
The offset must range from GMT-12 to GMT+14. The string must be an ISO 8601 time zone designator: e.g. Z e.g. +05 e.g. +0500 e.g. +05:00
Examples
use icu_timezone::GmtOffset;
let offset0: GmtOffset =
"Z".parse().expect("Failed to parse a GMT offset.");
let offset1: GmtOffset =
"-09".parse().expect("Failed to parse a GMT offset.");
let offset2: GmtOffset =
"-0930".parse().expect("Failed to parse a GMT offset.");
let offset3: GmtOffset =
"-09:30".parse().expect("Failed to parse a GMT offset.");
type Err = TimeZoneError
type Err = TimeZoneError
The associated error which can be returned from parsing.
impl Copy for GmtOffset
Auto Trait Implementations
impl RefUnwindSafe for GmtOffset
impl Send for GmtOffset
impl Sync for GmtOffset
impl Unpin for GmtOffset
impl UnwindSafe for GmtOffset
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more