[−][src]Struct datetime_string::rfc3339::TimeOffsetString
Owned string for a time in RFC 3339 time-offset format, such as +09:00, -00:00, and Z.
Examples
use datetime_string::rfc3339::TimeOffsetStr; use std::convert::TryFrom; let try_from = TimeOffsetString::try_from("-12:34")?; let parse = "-12:34".parse::<TimeOffsetString>()?; let parse2: TimeOffsetString = "-12:34".parse()?; let to_owned = TimeOffsetStr::from_str("-12:34")?.to_owned(); let into: TimeOffsetString = TimeOffsetStr::from_str("-12:34")?.into();
Implementations
impl TimeOffsetString[src]
#[must_use]pub fn as_deref(&self) -> &TimeOffsetStr[src]
Returns a &TimeOffsetStr for the string.
Examples
use datetime_string::rfc3339::TimeOffsetStr; let secfrac = "-12:34".parse::<TimeOffsetString>()?; // Usually you don't need to call `as_deref()` explicitly, because // `Deref<Target = TimeOffsetStr>` trait is implemented. let _: &TimeOffsetStr = secfrac.as_deref();
#[must_use]pub fn as_deref_mut(&mut self) -> &mut TimeOffsetStr[src]
Returns a &mut TimeOffsetStr for the string.
Examples
use datetime_string::rfc3339::TimeOffsetStr; let mut secfrac = "-12:34".parse::<TimeOffsetString>()?; // Usually you don't need to call `as_deref_mut()` explicitly, because // `DerefMut` trait is implemented. let _: &mut TimeOffsetStr = secfrac.as_deref_mut();
Methods from Deref<Target = TimeOffsetStr>
#[must_use]pub fn as_str(&self) -> &str[src]
Returns a string slice.
Examples
let time = TimeOffsetStr::from_str("-12:34")?; assert_eq!(time.as_str(), "-12:34");
#[must_use]pub fn as_bytes(&self) -> &[u8][src]
Returns a byte slice.
If you want to use indexed access, prefer as_bytes_fixed_len.
Examples
let time = TimeOffsetStr::from_str("-12:34")?; assert_eq!(time.as_bytes(), b"-12:34");
pub fn sign(&self) -> Option<TimeOffsetSign>[src]
Returns a sign if available.
Examples
use datetime_string::common::TimeOffsetSign; let positive = TimeOffsetStr::from_str("+12:34")?; assert_eq!(positive.sign(), Some(TimeOffsetSign::Positive)); let negative = TimeOffsetStr::from_str("-00:00")?; assert_eq!(negative.sign(), Some(TimeOffsetSign::Negative)); let zulu = TimeOffsetStr::from_str("Z")?; assert_eq!(zulu.sign(), None);
pub fn to_numoffset(&self) -> Option<&TimeNumOffsetStr>[src]
Returns a &TimeNumOffsetStr if the time offset is not Z.
Examples
let numoffset = TimeOffsetStr::from_str("+12:34")?; assert_eq!(numoffset.to_numoffset().unwrap().hour_abs(), 12); let zulu = TimeOffsetStr::from_str("Z")?; assert_eq!(zulu.to_numoffset(), None);
pub fn to_numoffset_mut(&mut self) -> Option<&mut TimeNumOffsetStr>[src]
Returns a &mut TimeNumOffsetStr if the time offset is not Z.
Examples
let mut buf_num = "+12:34".to_owned(); let numoffset = TimeOffsetStr::from_mut_str(&mut buf_num)?; numoffset.to_numoffset_mut().unwrap().set_hour_abs(23); assert_eq!(numoffset.as_str(), "+23:34"); assert_eq!(buf_num, "+23:34"); let mut buf_zulu = "Z".to_owned(); let zulu = TimeOffsetStr::from_mut_str(&mut buf_zulu)?; assert_eq!(zulu.to_numoffset_mut(), None);
#[must_use]pub fn hour_abs(&self) -> u8[src]
Returns the absolute hour as an integer.
Examples
let offset = TimeOffsetStr::from_str("-12:34")?; assert_eq!(offset.hour_abs(), 12); let zulu = TimeOffsetStr::from_str("Z")?; assert_eq!(zulu.hour_abs(), 0); let negative0 = TimeOffsetStr::from_str("-00:00")?; assert_eq!(negative0.hour_abs(), 0);
#[must_use]pub fn hour_signed(&self) -> i8[src]
Returns the signed hour as an integer.
Examples
let offset = TimeOffsetStr::from_str("-12:34")?; assert_eq!(offset.hour_signed(), -12); let zulu = TimeOffsetStr::from_str("Z")?; assert_eq!(zulu.hour_signed(), 0);
Note that both +00 and -00 are treaded as the same 0.
let positive = TimeOffsetStr::from_str("+00:59")?; assert_eq!(positive.hour_signed(), 0); let negative = TimeOffsetStr::from_str("-00:59")?; assert_eq!(negative.hour_signed(), 0);
#[must_use]pub fn minute(&self) -> u8[src]
Returns the minute as an integer.
Examples
let offset = TimeOffsetStr::from_str("-12:34")?; assert_eq!(offset.minute(), 34); let zulu = TimeOffsetStr::from_str("Z")?; assert_eq!(zulu.minute(), 0);
#[must_use]pub fn in_minutes(&self) -> i16[src]
Returns the time offset in minutes.
Note that both +00:00 and -00:00 is considered as 0 minutes offset.
RFC 3339 defines semantics of -00:00 as "unknown local offset".
If your application should be aware of that semantics, use
[is_unknown_local_offset] or [sign] to distinguish them.
Examples
let offset = TimeOffsetStr::from_str("-12:34")?; assert_eq!(offset.in_minutes(), -(12 * 60 + 34)); let zulu = TimeOffsetStr::from_str("Z")?; assert_eq!(zulu.in_minutes(), 0);
0 is returned for both +00:00 and -00:00.
use datetime_string::common::TimeOffsetSign; let positive0 = TimeOffsetStr::from_str("+00:00")?; assert_eq!(positive0.in_minutes(), 0); assert_eq!(positive0.sign(), Some(TimeOffsetSign::Positive)); assert!(!positive0.is_unknown_local_offset(), "0 minutes time offset"); let negative0 = TimeOffsetStr::from_str("-00:00")?; assert_eq!(negative0.in_minutes(), 0); assert_eq!(negative0.sign(), Some(TimeOffsetSign::Negative)); assert!(negative0.is_unknown_local_offset(), "unknown local offset");
#[must_use]pub fn is_unknown_local_offset(&self) -> bool[src]
Returns true if and only if the time offset means "unknown local offset" in RFC 3339.
RFC 3339 defines -00:00 as "unknown local offset".
If the time in UTC is known, but the offset to local time is unknown, this can be represented with an offset of "-00:00". This differs semantically from an offset of "Z" or "+00:00", which imply that UTC is the preferred reference point for the specified time.
This method returns true for -00:00.
Examples
use datetime_string::common::TimeOffsetSign; let positive0 = TimeOffsetStr::from_str("+00:00")?; assert!(!positive0.is_unknown_local_offset(), "0 minutes time offset"); let zulu = TimeOffsetStr::from_str("Z")?; assert!(!zulu.is_unknown_local_offset(), "UTC"); let negative0 = TimeOffsetStr::from_str("-00:00")?; assert!(negative0.is_unknown_local_offset(), "unknown local offset");
Trait Implementations
impl AsMut<TimeOffsetStr> for TimeOffsetString[src]
fn as_mut(&mut self) -> &mut TimeOffsetStr[src]
impl AsRef<[u8]> for TimeOffsetString[src]
impl AsRef<TimeOffsetStr> for TimeOffsetString[src]
fn as_ref(&self) -> &TimeOffsetStr[src]
impl AsRef<str> for TimeOffsetString[src]
impl Borrow<TimeOffsetStr> for TimeOffsetString[src]
fn borrow(&self) -> &TimeOffsetStr[src]
impl BorrowMut<TimeOffsetStr> for TimeOffsetString[src]
fn borrow_mut(&mut self) -> &mut TimeOffsetStr[src]
impl Clone for TimeOffsetString[src]
fn clone(&self) -> TimeOffsetString[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for TimeOffsetString[src]
impl Deref for TimeOffsetString[src]
type Target = TimeOffsetStr
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target[src]
impl DerefMut for TimeOffsetString[src]
impl<'de> Deserialize<'de> for TimeOffsetString[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>, [src]
D: Deserializer<'de>,
impl Display for TimeOffsetString[src]
impl Eq for TimeOffsetString[src]
impl<'_> From<&'_ TimeOffsetStr> for TimeOffsetString[src]
fn from(v: &TimeOffsetStr) -> Self[src]
impl From<TimeOffsetString> for Vec<u8>[src]
fn from(v: TimeOffsetString) -> Vec<u8>[src]
impl From<TimeOffsetString> for String[src]
fn from(v: TimeOffsetString) -> String[src]
impl FromStr for TimeOffsetString[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>[src]
impl Hash for TimeOffsetString[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl Ord for TimeOffsetString[src]
fn cmp(&self, other: &TimeOffsetString) -> Ordering[src]
#[must_use]fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self[src]
impl<'_> PartialEq<&'_ [u8]> for TimeOffsetString[src]
impl<'_> PartialEq<&'_ TimeOffsetStr> for TimeOffsetString[src]
impl<'_> PartialEq<&'_ TimeOffsetString> for TimeOffsetString[src]
fn eq(&self, o: &&TimeOffsetString) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialEq<&'_ TimeOffsetString> for str[src]
fn eq(&self, o: &&TimeOffsetString) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialEq<&'_ TimeOffsetString> for [u8][src]
fn eq(&self, o: &&TimeOffsetString) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialEq<&'_ str> for TimeOffsetString[src]
impl PartialEq<[u8]> for TimeOffsetString[src]
impl<'_> PartialEq<[u8]> for &'_ TimeOffsetString[src]
impl PartialEq<TimeOffsetStr> for TimeOffsetString[src]
impl PartialEq<TimeOffsetString> for TimeOffsetString[src]
fn eq(&self, other: &TimeOffsetString) -> bool[src]
fn ne(&self, other: &TimeOffsetString) -> bool[src]
impl<'_> PartialEq<TimeOffsetString> for &'_ TimeOffsetString[src]
fn eq(&self, o: &TimeOffsetString) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialEq<TimeOffsetString> for TimeOffsetStr[src]
fn eq(&self, o: &TimeOffsetString) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialEq<TimeOffsetString> for &'_ TimeOffsetStr[src]
fn eq(&self, o: &TimeOffsetString) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialEq<TimeOffsetString> for str[src]
fn eq(&self, o: &TimeOffsetString) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialEq<TimeOffsetString> for &'_ str[src]
fn eq(&self, o: &TimeOffsetString) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialEq<TimeOffsetString> for [u8][src]
fn eq(&self, o: &TimeOffsetString) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialEq<TimeOffsetString> for &'_ [u8][src]
fn eq(&self, o: &TimeOffsetString) -> bool[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialEq<str> for TimeOffsetString[src]
impl<'_> PartialEq<str> for &'_ TimeOffsetString[src]
impl<'_> PartialOrd<&'_ [u8]> for TimeOffsetString[src]
fn partial_cmp(&self, o: &&[u8]) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialOrd<&'_ TimeOffsetStr> for TimeOffsetString[src]
fn partial_cmp(&self, o: &&TimeOffsetStr) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialOrd<&'_ TimeOffsetString> for TimeOffsetString[src]
fn partial_cmp(&self, o: &&TimeOffsetString) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialOrd<&'_ TimeOffsetString> for str[src]
fn partial_cmp(&self, o: &&TimeOffsetString) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialOrd<&'_ TimeOffsetString> for [u8][src]
fn partial_cmp(&self, o: &&TimeOffsetString) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialOrd<&'_ str> for TimeOffsetString[src]
fn partial_cmp(&self, o: &&str) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialOrd<[u8]> for TimeOffsetString[src]
fn partial_cmp(&self, o: &[u8]) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialOrd<[u8]> for &'_ TimeOffsetString[src]
fn partial_cmp(&self, o: &[u8]) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialOrd<TimeOffsetStr> for TimeOffsetString[src]
fn partial_cmp(&self, o: &TimeOffsetStr) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialOrd<TimeOffsetString> for TimeOffsetString[src]
fn partial_cmp(&self, other: &TimeOffsetString) -> Option<Ordering>[src]
fn lt(&self, other: &TimeOffsetString) -> bool[src]
fn le(&self, other: &TimeOffsetString) -> bool[src]
fn gt(&self, other: &TimeOffsetString) -> bool[src]
fn ge(&self, other: &TimeOffsetString) -> bool[src]
impl<'_> PartialOrd<TimeOffsetString> for &'_ TimeOffsetString[src]
fn partial_cmp(&self, o: &TimeOffsetString) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialOrd<TimeOffsetString> for TimeOffsetStr[src]
fn partial_cmp(&self, o: &TimeOffsetString) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialOrd<TimeOffsetString> for &'_ TimeOffsetStr[src]
fn partial_cmp(&self, o: &TimeOffsetString) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialOrd<TimeOffsetString> for str[src]
fn partial_cmp(&self, o: &TimeOffsetString) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialOrd<TimeOffsetString> for &'_ str[src]
fn partial_cmp(&self, o: &TimeOffsetString) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialOrd<TimeOffsetString> for [u8][src]
fn partial_cmp(&self, o: &TimeOffsetString) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialOrd<TimeOffsetString> for &'_ [u8][src]
fn partial_cmp(&self, o: &TimeOffsetString) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl PartialOrd<str> for TimeOffsetString[src]
fn partial_cmp(&self, o: &str) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl<'_> PartialOrd<str> for &'_ TimeOffsetString[src]
fn partial_cmp(&self, o: &str) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl Serialize for TimeOffsetString[src]
impl StructuralEq for TimeOffsetString[src]
impl StructuralPartialEq for TimeOffsetString[src]
impl<'_> TryFrom<&'_ [u8]> for TimeOffsetString[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(v: &[u8]) -> Result<Self, Self::Error>[src]
impl<'_> TryFrom<&'_ str> for TimeOffsetString[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(v: &str) -> Result<Self, Self::Error>[src]
impl TryFrom<Vec<u8>> for TimeOffsetString[src]
Auto Trait Implementations
impl RefUnwindSafe for TimeOffsetString
impl Send for TimeOffsetString
impl Sync for TimeOffsetString
impl Unpin for TimeOffsetString
impl UnwindSafe for TimeOffsetString
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,