Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow getting the PrimitiveDateTime of a OffsetDateTime #458

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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