Skip to content

Commit

Permalink
Allow getting the PrimitiveDateTime of a OffsetDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
GunnarMorrigan committed Apr 11, 2022
1 parent a957e12 commit 0edb241
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/offset_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ impl OffsetDateTime {
pub const fn offset(self) -> UtcOffset {
self.offset
}


// region: getters
/// Get the [`PrimitiveDateTime`].
///
/// ```rust
/// # use time::macros::{datetime};
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).primitive_date_time(), datetime!(2019-01-01 0:00));
/// assert_eq!(datetime!(2019-01-01 0:00 +1).primitive_date_time(), datetime!(2019-01-01 0:00));
/// ```
pub const fn primitive_date_time(self) -> PrimitiveDateTime {
self.utc_datetime
}

/// Get the [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time).
///
Expand Down

0 comments on commit 0edb241

Please sign in to comment.