pub trait DateTimeParts: Ord {
// Required methods
fn year(&self) -> i32;
fn month(&self) -> u8;
fn day(&self) -> u8;
fn hour(&self) -> u8;
fn minute(&self) -> u8;
fn second(&self) -> u8;
fn nanosecond(&self) -> u32;
}Expand description
A trait to expose the date and time fields used by this crate.
The fields describe the wall-clock date and time of the value. Each method must return a value in the range written in its documentation, otherwise the functions of this crate may panic.
This trait is also implemented for chrono types.
If chrono::Datelike or chrono::Timelike is in scope at the same time (for example, by use chrono::prelude::*; and use date_differencer::*;), calling a method such as year() on a chrono value is ambiguous and does not compile.
To avoid this, import only the items you need from this crate (for example, use date_differencer::{date_diff, date_time_diff};), or call the method with its full path (for example, Datelike::year(&date_time)).
Required Methods§
Sourcefn nanosecond(&self) -> u32
fn nanosecond(&self) -> u32
Returns the nanosecond, from 0 to 999_999_999.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl DateTimeParts for DateTime
Available on crate feature jiff only.
impl DateTimeParts for DateTime
jiff only.Source§impl DateTimeParts for NaiveDateTime
Available on crate feature chrono only.
impl DateTimeParts for NaiveDateTime
chrono only.Source§impl DateTimeParts for OffsetDateTime
Available on crate feature time only.
impl DateTimeParts for OffsetDateTime
time only.Source§impl DateTimeParts for PrimitiveDateTime
Available on crate feature time only.
impl DateTimeParts for PrimitiveDateTime
time only.Source§impl DateTimeParts for UtcDateTime
Available on crate feature time only.
impl DateTimeParts for UtcDateTime
time only.Source§impl DateTimeParts for Zoned
Available on crate feature jiff only.
impl DateTimeParts for Zoned
jiff only.Source§impl<Tz> DateTimeParts for DateTime<Tz>
Available on crate feature chrono only.
impl<Tz> DateTimeParts for DateTime<Tz>
chrono only.