[−][src]Struct datetime_string::rfc3339::DateTimeStr
String slice for a datetime in RFC 3339 date-time
format, such as
2001-06-17T12:34:56.7890-23:12
.
Implementations
impl DateTimeStr
[src]
pub fn from_str(s: &str) -> Result<&Self, Error>
[src]
Creates a new &DateTimeStr
from 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"); assert!(DateTimeStr::from_str("2000-02-29T12:34:56Z").is_ok()); assert!(DateTimeStr::from_str("9999-12-31T23:59:59+23:59").is_ok()); assert!(DateTimeStr::from_str("0000-01-01T00:00:00.0-00:00").is_ok());
pub fn from_mut_str(s: &mut str) -> Result<&mut Self, Error>
[src]
Creates a new &mut DateTimeStr
from a mutable string slice.
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"); datetime.date_mut().set_year(1999); assert_eq!(datetime.as_str(), "1999-06-17T12:34:56.7890-23:12");
pub fn from_bytes(s: &[u8]) -> Result<&Self, Error>
[src]
Creates a new &DateTimeStr
from a byte slice.
Examples
let datetime = DateTimeStr::from_bytes(b"2001-06-17T12:34:56.7890-23:12")?; assert_eq!(datetime.as_str(), "2001-06-17T12:34:56.7890-23:12"); assert!(DateTimeStr::from_bytes(b"2001-06-17T12:34:56Z").is_ok()); assert!(DateTimeStr::from_bytes(b"9999-12-31T23:59:59+23:59").is_ok()); assert!(DateTimeStr::from_bytes(b"0000-01-01T00:00:00.0-00:00").is_ok());
pub fn from_bytes_mut(s: &mut [u8]) -> Result<&mut Self, Error>
[src]
Creates a new &mut DateTimeStr
from a mutable byte slice.
Examples
let mut buf = b"2001-06-17T12:34:56.7890-23:12".to_owned(); let datetime = DateTimeStr::from_bytes_mut(&mut buf[..])?; assert_eq!(datetime.as_str(), "2001-06-17T12:34:56.7890-23:12"); datetime.date_mut().set_year(1999); assert_eq!(datetime.as_str(), "1999-06-17T12:34:56.7890-23:12");
#[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 AsMut<DateTimeStr> for DateTimeStr
[src]
fn as_mut(&mut self) -> &mut DateTimeStr
[src]
impl AsRef<[u8]> for DateTimeStr
[src]
impl AsRef<DateTimeStr> for DateTimeString
[src]
fn as_ref(&self) -> &DateTimeStr
[src]
impl AsRef<DateTimeStr> for DateTimeStr
[src]
fn as_ref(&self) -> &DateTimeStr
[src]
impl AsRef<str> for DateTimeStr
[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 Debug for DateTimeStr
[src]
impl Deref for DateTimeStr
[src]
impl<'de> Deserialize<'de> for &'de DateTimeStr
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for DateTimeStr
[src]
impl Eq for DateTimeStr
[src]
impl<'_> From<&'_ DateTimeStr> for DateTimeString
[src]
fn from(v: &DateTimeStr) -> Self
[src]
impl<'a> From<&'a DateTimeStr> for &'a str
[src]
fn from(v: &'a DateTimeStr) -> Self
[src]
impl Hash for DateTimeStr
[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 DateTimeStr
[src]
fn cmp(&self, other: &DateTimeStr) -> 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 DateTimeStr
[src]
impl<'_> PartialEq<&'_ DateTimeStr> for DateTimeString
[src]
impl<'_> PartialEq<&'_ DateTimeStr> for DateTimeStr
[src]
impl<'_> PartialEq<&'_ DateTimeStr> for [u8]
[src]
impl<'_> PartialEq<&'_ DateTimeStr> for str
[src]
impl<'_> PartialEq<&'_ str> for DateTimeStr
[src]
impl PartialEq<[u8]> for DateTimeStr
[src]
impl<'_> PartialEq<[u8]> for &'_ DateTimeStr
[src]
impl PartialEq<DateTimeStr> for DateTimeString
[src]
impl PartialEq<DateTimeStr> for DateTimeStr
[src]
fn eq(&self, other: &DateTimeStr) -> bool
[src]
fn ne(&self, other: &DateTimeStr) -> bool
[src]
impl<'_> PartialEq<DateTimeStr> for &'_ DateTimeStr
[src]
impl PartialEq<DateTimeStr> for [u8]
[src]
impl<'_> PartialEq<DateTimeStr> for &'_ [u8]
[src]
impl PartialEq<DateTimeStr> for str
[src]
impl<'_> PartialEq<DateTimeStr> for &'_ str
[src]
impl PartialEq<DateTimeString> for DateTimeStr
[src]
impl<'_> PartialEq<DateTimeString> for &'_ DateTimeStr
[src]
impl PartialEq<str> for DateTimeStr
[src]
impl<'_> PartialEq<str> for &'_ DateTimeStr
[src]
impl<'_> PartialOrd<&'_ [u8]> for DateTimeStr
[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<&'_ DateTimeStr> for DateTimeStr
[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<&'_ DateTimeStr> for [u8]
[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<&'_ DateTimeStr> for str
[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<&'_ str> for DateTimeStr
[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 DateTimeStr
[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 &'_ DateTimeStr
[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<DateTimeStr> for DateTimeStr
[src]
fn partial_cmp(&self, other: &DateTimeStr) -> Option<Ordering>
[src]
fn lt(&self, other: &DateTimeStr) -> bool
[src]
fn le(&self, other: &DateTimeStr) -> bool
[src]
fn gt(&self, other: &DateTimeStr) -> bool
[src]
fn ge(&self, other: &DateTimeStr) -> bool
[src]
impl<'_> PartialOrd<DateTimeStr> for &'_ DateTimeStr
[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<DateTimeStr> for [u8]
[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<DateTimeStr> for &'_ [u8]
[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<DateTimeStr> for str
[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<DateTimeStr> for &'_ str
[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 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<str> for DateTimeStr
[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 &'_ DateTimeStr
[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 DateTimeStr
[src]
impl StructuralEq for DateTimeStr
[src]
impl StructuralPartialEq for DateTimeStr
[src]
impl ToOwned for DateTimeStr
[src]
type Owned = DateTimeString
The resulting type after obtaining ownership.
fn to_owned(&self) -> Self::Owned
[src]
fn clone_into(&self, target: &mut Self::Owned)
[src]
impl<'a> TryFrom<&'a [u8]> for &'a DateTimeStr
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(v: &'a [u8]) -> Result<Self, Self::Error>
[src]
impl<'a> TryFrom<&'a mut [u8]> for &'a mut DateTimeStr
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(v: &'a mut [u8]) -> Result<Self, Self::Error>
[src]
impl<'a> TryFrom<&'a mut str> for &'a mut DateTimeStr
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(v: &'a mut str) -> Result<Self, Self::Error>
[src]
impl<'a> TryFrom<&'a str> for &'a DateTimeStr
[src]
Auto Trait Implementations
impl RefUnwindSafe for DateTimeStr
impl Send for DateTimeStr
impl Sync for DateTimeStr
impl Unpin for DateTimeStr
impl UnwindSafe for DateTimeStr
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> 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,