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 RFC 5322 date and time with its zone offset.
Fields§
§year: u16Year, four digits.
month: u8Month, 1 to 12.
day: u8Day of the month, 1 to 31.
hour: u8Hour, 0 to 23.
minute: u8Minute, 0 to 59.
second: u8Second, 0 to 59.
tz_before_gmt: boolWhether the zone offset is negative (west of UTC).
tz_hour: u8Hours of the zone offset.
tz_minute: u8Minutes of the zone offset.
Implementations§
Source§impl DateTime
impl DateTime
Sourcepub fn parse_rfc822(value: &str) -> Option<Self>
pub fn parse_rfc822(value: &str) -> Option<Self>
Parses an RFC 5322 date with the header date parser.
Sourcepub fn parse_rfc3339(value: &str) -> Option<Self>
pub fn parse_rfc3339(value: &str) -> Option<Self>
Parses an RFC 3339 date.
Sourcepub fn to_rfc3339(&self) -> String
pub fn to_rfc3339(&self) -> String
Formats the date as RFC 3339.
Sourcepub fn to_timestamp(&self) -> i64
pub fn to_timestamp(&self) -> i64
Seconds since the Unix epoch, applying the zone offset.
Sourcepub fn to_timestamp_local(&self) -> i64
pub fn to_timestamp_local(&self) -> i64
Seconds since the Unix epoch, ignoring the zone offset.
Sourcepub fn from_timestamp(timestamp: i64) -> Self
pub fn from_timestamp(timestamp: i64) -> Self
Creates a UTC date from seconds since the Unix epoch.
Sourcepub fn day_of_week(&self) -> u8
pub fn day_of_week(&self) -> u8
Day of the week, 0 (Sunday) to 6 (Saturday).
Sourcepub fn julian_day(&self) -> i64
pub fn julian_day(&self) -> i64
Julian day number.
Sourcepub fn to_timezone(&self, tz: i64) -> DateTime
pub fn to_timezone(&self, tz: i64) -> DateTime
The same instant in a zone tz seconds away from UTC. Offsets too
large for the fields saturate instead of overflowing.
Trait Implementations§
impl Copy for DateTime
impl Eq for DateTime
Source§impl Ord for DateTime
impl Ord for DateTime
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations§
impl Freeze for DateTime
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnsafeUnpin for DateTime
impl UnwindSafe for DateTime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more