pub struct OffsetDateTime { /* private fields */ }Expand description
An instant together with a fixed UTC offset, as parsed from RFC 3339.
Equality, ordering and hashing look at the instant only, as chrono’s
DateTime<FixedOffset> did: 11:00+01:00 == 10:00Z.
Implementations§
Source§impl OffsetDateTime
impl OffsetDateTime
Sourcepub fn parse_from_rfc3339(s: &str) -> Result<Self, ParseError>
pub fn parse_from_rfc3339(s: &str) -> Result<Self, ParseError>
Strict RFC 3339, keeping the offset.
Sourcepub const fn to_utc(self) -> UtcDateTime
pub const fn to_utc(self) -> UtcDateTime
The instant in UTC.
Sourcepub const fn offset_seconds(self) -> i32
pub const fn offset_seconds(self) -> i32
Seconds east of UTC.
Sourcepub fn timestamp_millis(self) -> i64
pub fn timestamp_millis(self) -> i64
Unix milliseconds.
Sourcepub fn signed_duration_since(self, other: impl Into<UtcDateTime>) -> Duration
pub fn signed_duration_since(self, other: impl Into<UtcDateTime>) -> Duration
self - other as a signed duration.
Sourcepub fn checked_add_signed(self, d: Duration) -> Option<Self>
pub fn checked_add_signed(self, d: Duration) -> Option<Self>
self + d in the same offset, None outside the range.
Sourcepub fn checked_sub_signed(self, d: Duration) -> Option<Self>
pub fn checked_sub_signed(self, d: Duration) -> Option<Self>
self - d in the same offset, None outside the range.
Sourcepub fn to_rfc3339(self) -> String
pub fn to_rfc3339(self) -> String
RFC 3339 in the original offset (+00:00 for UTC).
Sourcepub fn to_rfc3339_opts(self, secform: SecondsFormat, use_z: bool) -> String
pub fn to_rfc3339_opts(self, secform: SecondsFormat, use_z: bool) -> String
RFC 3339 in the original offset with the given precision; use_z
writes Z for a zero offset, like chrono.
Sourcepub fn timestamp_subsec_nanos(self) -> u32
pub fn timestamp_subsec_nanos(self) -> u32
The nanoseconds past OffsetDateTime::timestamp.
Sourcepub fn to_local(self) -> LocalDateTime
pub fn to_local(self) -> LocalDateTime
The same instant in the system time zone.
Trait Implementations§
Source§impl Add<Duration> for OffsetDateTime
impl Add<Duration> for OffsetDateTime
Source§impl Clone for OffsetDateTime
impl Clone for OffsetDateTime
impl Copy for OffsetDateTime
Source§impl Debug for OffsetDateTime
impl Debug for OffsetDateTime
Source§impl Display for OffsetDateTime
impl Display for OffsetDateTime
impl Eq for OffsetDateTime
Source§impl From<OffsetDateTime> for UtcDateTime
impl From<OffsetDateTime> for UtcDateTime
Source§fn from(t: OffsetDateTime) -> Self
fn from(t: OffsetDateTime) -> Self
Converts to this type from the input type.
Source§impl Hash for OffsetDateTime
impl Hash for OffsetDateTime
Source§impl Ord for OffsetDateTime
impl Ord for OffsetDateTime
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 PartialEq for OffsetDateTime
impl PartialEq for OffsetDateTime
Source§impl PartialEq<OffsetDateTime> for UtcDateTime
impl PartialEq<OffsetDateTime> for UtcDateTime
Source§impl PartialEq<UtcDateTime> for OffsetDateTime
impl PartialEq<UtcDateTime> for OffsetDateTime
Source§impl PartialOrd for OffsetDateTime
impl PartialOrd for OffsetDateTime
Source§impl PartialOrd<OffsetDateTime> for UtcDateTime
impl PartialOrd<OffsetDateTime> for UtcDateTime
Source§impl PartialOrd<UtcDateTime> for OffsetDateTime
impl PartialOrd<UtcDateTime> for OffsetDateTime
Source§impl Sub for OffsetDateTime
impl Sub for OffsetDateTime
Source§impl Sub<Duration> for OffsetDateTime
impl Sub<Duration> for OffsetDateTime
Source§impl Sub<OffsetDateTime> for UtcDateTime
impl Sub<OffsetDateTime> for UtcDateTime
Source§impl Sub<UtcDateTime> for OffsetDateTime
impl Sub<UtcDateTime> for OffsetDateTime
Auto Trait Implementations§
impl Forget for OffsetDateTime
impl Freeze for OffsetDateTime
impl Move for OffsetDateTime
impl RefUnwindSafe for OffsetDateTime
impl Send for OffsetDateTime
impl Sync for OffsetDateTime
impl Unpin for OffsetDateTime
impl UnsafeUnpin for OffsetDateTime
impl UnwindSafe for OffsetDateTime
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