Struct mail_parser::DateTime
source · [−]pub struct DateTime {
pub year: u16,
pub month: u8,
pub day: u8,
pub hour: u8,
pub minute: u8,
pub second: u8,
pub tz_before_gmt: bool,
pub tz_hour: u8,
pub tz_minute: u8,
}
Expand description
An RFC5322 datetime.
Fields
year: u16
month: u8
day: u8
hour: u8
minute: u8
second: u8
tz_before_gmt: bool
tz_hour: u8
tz_minute: u8
Implementations
sourceimpl DateTime
impl DateTime
sourcepub fn parse_rfc822(&self, value: &str) -> Option<Self>
pub fn parse_rfc822(&self, value: &str) -> Option<Self>
Parses an RFC822 date
sourcepub fn parse_rfc3339(value: &str) -> Option<Self>
pub fn parse_rfc3339(value: &str) -> Option<Self>
Parses an RFC3339 date
sourcepub fn to_rfc3339(&self) -> String
pub fn to_rfc3339(&self) -> String
Returns an RFC3339 representation of the parsed RFC5322 datetime field
sourcepub fn to_timestamp(&self) -> i64
pub fn to_timestamp(&self) -> i64
Returns the numbers of seconds since 1970-01-01T00:00:00Z (Unix epoch) or None if the date is invalid.
sourcepub fn to_timestamp_local(&self) -> i64
pub fn to_timestamp_local(&self) -> i64
Returns the numbers of seconds since 1970-01-01T00:00:00Z (Unix epoch) in local time or None if the date is invalid.
sourcepub fn from_timestamp(timestamp: i64) -> Self
pub fn from_timestamp(timestamp: i64) -> Self
Creates a DateTime object from a timestamp
sourcepub fn day_of_week(&self) -> u8
pub fn day_of_week(&self) -> u8
Returns the day of week where [0, 6] represents [Sun, Sat].
sourcepub fn julian_day(&self) -> i64
pub fn julian_day(&self) -> i64
Returns the julian day
sourcepub fn to_timezone(&self, tz: i64) -> DateTime
pub fn to_timezone(&self, tz: i64) -> DateTime
Converts the DateTime to the given timezone
Trait Implementations
sourceimpl Ord for DateTime
impl Ord for DateTime
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<DateTime> for DateTime
impl PartialOrd<DateTime> for DateTime
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for DateTime
impl StructuralEq for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnwindSafe for DateTime
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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