Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions time/src/offset_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,21 @@ impl OffsetDateTime {
)
}

/// Convert the `OffsetDateTime` to a `PrimitiveDateTime` in whatever offset
/// it happens to be.
///
/// ```rust
/// # use time_macros::datetime;
/// assert_eq!(
/// datetime!(2000-01-01 0:00 UTC).to_primitive(),
/// datetime!(2000-01-01 0:00),
/// );
/// ```
#[inline]
pub const fn to_primitive(self) -> PrimitiveDateTime {
PrimitiveDateTime::new(self.date(), self.time())
}

/// Create an `OffsetDateTime` from the provided Unix timestamp. Calling `.offset()` on the
/// resulting value is guaranteed to return UTC.
///
Expand Down
Loading