pub trait StrTime {
// Provided methods
fn parse_time<T: Time>(&self, format: &str) -> T
where Self: Display { ... }
fn strp_iso8601<T: Time>(&self) -> T
where Self: Display { ... }
fn strp_rf3339<T: Time>(&self) -> T
where Self: Display { ... }
}Expand description
Provides wrappers on string std types to parse into time structs
Provided Methods§
Sourcefn parse_time<T: Time>(&self, format: &str) -> Twhere
Self: Display,
fn parse_time<T: Time>(&self, format: &str) -> Twhere
Self: Display,
Parse a string into a time struct of choice
§Examples
use thetime::{System, Time, StrTime};
println!("2017 - {}", "2017-01-01 00:00:00".parse_time::<System>("%Y-%m-%d %H:%M:%S"));
println!("{}", "2017-01-01 00:00:00".parse_time::<System>("%Y-%m-%d %H:%M:%S").unix());
assert_eq!("2017-01-01 00:00:00".parse_time::<System>("%Y-%m-%d %H:%M:%S").unix(), 1483228800);Sourcefn strp_iso8601<T: Time>(&self) -> Twhere
Self: Display,
fn strp_iso8601<T: Time>(&self) -> Twhere
Self: Display,
Parse a string into a time struct of choice, using the ISO8601 format
§Examples
use thetime::{System, Time, StrTime};
println!("2017 - {}", "2017-01-01T00:00:00.000".strp_iso8601::<System>());
println!("{}", "2017-01-01T00:00:00.000".strp_iso8601::<System>().unix());
assert_eq!("2017-01-01T00:00:00.000".strp_iso8601::<System>().unix(), 1483228800);Sourcefn strp_rf3339<T: Time>(&self) -> Twhere
Self: Display,
fn strp_rf3339<T: Time>(&self) -> Twhere
Self: Display,
Parse a string into a time struct of choice, using the RFC3339 format
§Examples
use thetime::{System, Time, StrTime};
println!("2017 - {}", "2017-01-01T00:00:00.000Z".strp_rf3339::<System>());
println!("{}", "2017-01-01T00:00:00.000Z".strp_rf3339::<System>().unix());
assert_eq!("2017-01-01T00:00:00.000Z".strp_rf3339::<System>().unix(), 1483228800);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
impl StrTime for str
implement the StrTime trait for String types
impl StrTime for String
implement the StrTime trait for &str types