[−][src]Struct datetime_string::rfc3339::DateTimeString
Owned string for a datetime in RFC 3339 date-time
format, such as
2001-06-17T12:34:56.7890-23:12
.
Available when alloc
feature is enabled.
Examples
use datetime_string::rfc3339::DateTimeStr; use std::convert::TryFrom; let try_from = DateTimeString::try_from("2001-06-17T12:34:56.7890-23:12")?; let parse = "2001-06-17T12:34:56.7890-23:12".parse::<DateTimeString>()?; let parse2: DateTimeString = "2001-06-17T12:34:56.7890-23:12".parse()?; let to_owned = DateTimeStr::from_str("2001-06-17T12:34:56.7890-23:12")?.to_owned(); let into: DateTimeString = DateTimeStr::from_str("2001-06-17T12:34:56.7890-23:12")?.into();
Implementations
impl DateTimeString
[src]
#[must_use]pub fn as_deref(&self) -> &DateTimeStr
[src]
Returns a &DateTimeStr
for the string.
Examples
use datetime_string::rfc3339::DateTimeStr; let datetime = "2001-06-17T12:34:56.7890-23:12".parse::<DateTimeString>()?; // Usually you don't need to call `as_deref()` explicitly, because // `Deref<Target = DateTimeStr>` trait is implemented. let _: &DateTimeStr = datetime.as_deref();
#[must_use]pub fn as_deref_mut(&mut self) -> &mut DateTimeStr
[src]
Returns a &mut DateTimeStr
for the string.
Examples
use datetime_string::rfc3339::DateTimeStr; let mut datetime = "2001-06-17T12:34:56.7890-23:12".parse::<DateTimeString>()?; // Usually you don't need to call `as_deref_mut()` explicitly, because // `DerefMut` trait is implemented. let _: &mut DateTimeStr = datetime.as_deref_mut();
Methods from Deref<Target = DateTimeStr>
#[must_use]pub fn as_str(&self) -> &str
[src]
Returns a string slice.
Examples
let datetime = DateTimeStr::from_str("2001-06-17T12:34:56.7890-23:12")?; assert_eq!(datetime.as_str(), "2001-06-17T12:34:56.7890-23:12");
#[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 datetime = DateTimeStr::from_str("2001-06-17T12:34:56.7890-23:12")?; assert_eq!(datetime.as_bytes(), b"2001-06-17T12:34:56.7890-23:12");
#[must_use]pub fn decompose(&self) -> (&FullDateStr, &FullTimeStr)
[src]
Decomposes the string into &FullDateStr
and &FullTimeStr
.
Examples
let datetime = DateTimeStr::from_str("2001-06-17T12:34:56.7890-23:12")?; assert_eq!(datetime.as_str(), "2001-06-17T12:34:56.7890-23:12"); let (date, time) = datetime.decompose(); assert_eq!(date.as_str(), "2001-06-17"); assert_eq!(time.as_str(), "12:34:56.7890-23:12");
#[must_use]pub fn decompose_mut(&mut self) -> (&mut FullDateStr, &mut FullTimeStr)
[src]
Decomposes the string into &mut FullDateStr
and &mut FullTimeStr
.
Examples
use datetime_string::common::TimeOffsetSign; let mut buf = "2001-06-17T12:34:56.7890-23:12".to_owned(); let datetime = DateTimeStr::from_mut_str(&mut buf)?; assert_eq!(datetime.as_str(), "2001-06-17T12:34:56.7890-23:12"); let (date, time) = datetime.decompose_mut(); assert_eq!(date.as_str(), "2001-06-17"); assert_eq!(time.as_str(), "12:34:56.7890-23:12"); date.set_year(1999)?; time.partial_time_mut().secfrac_mut().unwrap().digits_mut().fill_with_zero(); assert_eq!(datetime.as_str(), "1999-06-17T12:34:56.0000-23:12");
#[must_use]pub fn date(&self) -> &FullDateStr
[src]
Returns a &FullDateStr
.
Examples
let datetime = DateTimeStr::from_str("2001-06-17T12:34:56.7890-23:12")?; assert_eq!(datetime.as_str(), "2001-06-17T12:34:56.7890-23:12"); let date = datetime.date(); assert_eq!(date.as_str(), "2001-06-17");
#[must_use]pub fn date_mut(&mut self) -> &mut FullDateStr
[src]
Returns a &mut FullDateStr
.
Examples
let mut buf = "2001-06-17T12:34:56.7890-23:12".to_owned(); let datetime = DateTimeStr::from_mut_str(&mut buf)?; assert_eq!(datetime.as_str(), "2001-06-17T12:34:56.7890-23:12"); let date = datetime.date_mut(); assert_eq!(date.as_str(), "2001-06-17"); date.set_year(1999)?; assert_eq!(datetime.as_str(), "1999-06-17T12:34:56.7890-23:12");
#[must_use]pub fn time(&self) -> &FullTimeStr
[src]
Returns a &FullTimeStr
.
Examples
let datetime = DateTimeStr::from_str("2001-06-17T12:34:56.7890-23:12")?; assert_eq!(datetime.as_str(), "2001-06-17T12:34:56.7890-23:12"); let time = datetime.time(); assert_eq!(time.as_str(), "12:34:56.7890-23:12");
#[must_use]pub fn time_mut(&mut self) -> &mut FullTimeStr
[src]
Returns a &mut FullTimeStr
.
Examples
use datetime_string::common::TimeOffsetSign; let mut buf = "2001-06-17T12:34:56.7890-23:12".to_owned(); let datetime = DateTimeStr::from_mut_str(&mut buf)?; assert_eq!(datetime.as_str(), "2001-06-17T12:34:56.7890-23:12"); let time = datetime.time_mut(); assert_eq!(time.as_str(), "12:34:56.7890-23:12"); time.partial_time_mut().secfrac_mut().unwrap().digits_mut().fill_with_zero(); assert_eq!(datetime.as_str(), "2001-06-17T12:34:56.0000-23:12");
pub fn to_chrono_date_time(&self) -> DateTime<FixedOffset>
[src]
Converts the time to chrono::DateTime<FixedOffset>
.
Note that this truncates subnanosecond secfrac.
Enabled by chrono04
feature.
Examples
use chrono04::{FixedOffset, TimeZone}; let datetime = DateTimeStr::from_str("1999-12-31T12:34:56.01234567899999+09:00")?; assert_eq!( datetime.to_chrono_date_time(), FixedOffset::east(9 * 60 * 60).ymd(1999, 12, 31).and_hms_nano(12, 34, 56, 12_345_678) ); let leap = DateTimeStr::from_str("2001-12-31T23:59:60.876543210999-00:00")?; assert_eq!( leap.to_chrono_date_time(), FixedOffset::east(0).ymd(2001, 12, 31).and_hms_nano(23, 59, 59, 1_876_543_210) );
Trait Implementations
impl AsMut<DateTimeStr> for DateTimeString
[src]
fn as_mut(&mut self) -> &mut DateTimeStr
[src]
impl AsRef<[u8]> for DateTimeString
[src]
impl AsRef<DateTimeStr> for DateTimeString
[src]
fn as_ref(&self) -> &DateTimeStr
[src]
impl AsRef<str> for DateTimeString
[src]
impl Borrow<DateTimeStr> for DateTimeString
[src]
fn borrow(&self) -> &DateTimeStr
[src]
impl BorrowMut<DateTimeStr> for DateTimeString
[src]
fn borrow_mut(&mut self) -> &mut DateTimeStr
[src]
impl Clone for DateTimeString
[src]
fn clone(&self) -> DateTimeString
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for DateTimeString
[src]
impl Deref for DateTimeString
[src]
type Target = DateTimeStr
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl DerefMut for DateTimeString
[src]
impl<'de> Deserialize<'de> for DateTimeString
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for DateTimeString
[src]
impl Eq for DateTimeString
[src]
impl<'_> From<&'_ DateTimeStr> for DateTimeString
[src]
fn from(v: &DateTimeStr) -> Self
[src]
impl From<DateTimeString> for Vec<u8>
[src]
fn from(v: DateTimeString) -> Vec<u8>
[src]
impl From<DateTimeString> for String
[src]
fn from(v: DateTimeString) -> String
[src]
impl FromStr for DateTimeString
[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 DateTimeString
[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 DateTimeString
[src]
fn cmp(&self, other: &DateTimeString) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'_> PartialEq<&'_ [u8]> for DateTimeString
[src]
impl<'_> PartialEq<&'_ DateTimeStr> for DateTimeString
[src]
impl<'_> PartialEq<&'_ DateTimeString> for DateTimeString
[src]
fn eq(&self, o: &&DateTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<&'_ DateTimeString> for str
[src]
fn eq(&self, o: &&DateTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<&'_ DateTimeString> for [u8]
[src]
fn eq(&self, o: &&DateTimeString) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<&'_ str> for DateTimeString
[src]
impl PartialEq<[u8]> for DateTimeString
[src]
impl<'_> PartialEq<[u8]> for &'_ DateTimeString
[src]
impl PartialEq<DateTimeStr> for DateTimeString
[src]
impl PartialEq<DateTimeString> for DateTimeString
[src]
fn eq(&self, other: &DateTimeString) -> bool
[src]
fn ne(&self, other: &DateTimeString) -> bool
[src]
impl<'_> PartialEq<DateTimeString> for &'_ DateTimeString
[src]
impl PartialEq<DateTimeString> for DateTimeStr
[src]
impl<'_> PartialEq<DateTimeString> for &'_ DateTimeStr
[src]
impl PartialEq<DateTimeString> for str
[src]
impl<'_> PartialEq<DateTimeString> for &'_ str
[src]
impl PartialEq<DateTimeString> for [u8]
[src]
impl<'_> PartialEq<DateTimeString> for &'_ [u8]
[src]
impl PartialEq<str> for DateTimeString
[src]
impl<'_> PartialEq<str> for &'_ DateTimeString
[src]
impl<'_> PartialOrd<&'_ [u8]> for DateTimeString
[src]
fn partial_cmp(&self, o: &&[u8]) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ DateTimeStr> for DateTimeString
[src]
fn partial_cmp(&self, o: &&DateTimeStr) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ DateTimeString> for DateTimeString
[src]
fn partial_cmp(&self, o: &&DateTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ DateTimeString> for str
[src]
fn partial_cmp(&self, o: &&DateTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ DateTimeString> for [u8]
[src]
fn partial_cmp(&self, o: &&DateTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<&'_ str> for DateTimeString
[src]
fn partial_cmp(&self, o: &&str) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<[u8]> for DateTimeString
[src]
fn partial_cmp(&self, o: &[u8]) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<[u8]> for &'_ DateTimeString
[src]
fn partial_cmp(&self, o: &[u8]) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<DateTimeStr> for DateTimeString
[src]
fn partial_cmp(&self, o: &DateTimeStr) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<DateTimeString> for DateTimeString
[src]
fn partial_cmp(&self, other: &DateTimeString) -> Option<Ordering>
[src]
fn lt(&self, other: &DateTimeString) -> bool
[src]
fn le(&self, other: &DateTimeString) -> bool
[src]
fn gt(&self, other: &DateTimeString) -> bool
[src]
fn ge(&self, other: &DateTimeString) -> bool
[src]
impl<'_> PartialOrd<DateTimeString> for &'_ DateTimeString
[src]
fn partial_cmp(&self, o: &DateTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<DateTimeString> for DateTimeStr
[src]
fn partial_cmp(&self, o: &DateTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<DateTimeString> for &'_ DateTimeStr
[src]
fn partial_cmp(&self, o: &DateTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<DateTimeString> for str
[src]
fn partial_cmp(&self, o: &DateTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<DateTimeString> for &'_ str
[src]
fn partial_cmp(&self, o: &DateTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<DateTimeString> for [u8]
[src]
fn partial_cmp(&self, o: &DateTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<DateTimeString> for &'_ [u8]
[src]
fn partial_cmp(&self, o: &DateTimeString) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<str> for DateTimeString
[src]
fn partial_cmp(&self, o: &str) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialOrd<str> for &'_ DateTimeString
[src]
fn partial_cmp(&self, o: &str) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for DateTimeString
[src]
impl StructuralEq for DateTimeString
[src]
impl StructuralPartialEq for DateTimeString
[src]
impl<'_> TryFrom<&'_ [u8]> for DateTimeString
[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 DateTimeString
[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<String> for DateTimeString
[src]
type Error = ConversionError<String>
The type returned in the event of a conversion error.
fn try_from(v: String) -> Result<Self, Self::Error>
[src]
impl TryFrom<Vec<u8>> for DateTimeString
[src]
Auto Trait Implementations
impl RefUnwindSafe for DateTimeString
impl Send for DateTimeString
impl Sync for DateTimeString
impl Unpin for DateTimeString
impl UnwindSafe for DateTimeString
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>,