Skip to main content

DateTimeParts

Trait DateTimeParts 

Source
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§

Source

fn year(&self) -> i32

Returns the year.

Source

fn month(&self) -> u8

Returns the month, from 1 to 12.

Source

fn day(&self) -> u8

Returns the day of the month, from 1 to the number of days in the month.

Source

fn hour(&self) -> u8

Returns the hour, from 0 to 23.

Source

fn minute(&self) -> u8

Returns the minute, from 0 to 59.

Source

fn second(&self) -> u8

Returns the second, from 0 to 59.

Source

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.
Source§

fn year(&self) -> i32

Source§

fn month(&self) -> u8

Source§

fn day(&self) -> u8

Source§

fn hour(&self) -> u8

Source§

fn minute(&self) -> u8

Source§

fn second(&self) -> u8

Source§

fn nanosecond(&self) -> u32

Source§

impl DateTimeParts for NaiveDateTime

Available on crate feature chrono only.
Source§

fn year(&self) -> i32

Source§

fn month(&self) -> u8

Source§

fn day(&self) -> u8

Source§

fn hour(&self) -> u8

Source§

fn minute(&self) -> u8

Source§

fn second(&self) -> u8

Source§

fn nanosecond(&self) -> u32

Source§

impl DateTimeParts for OffsetDateTime

Available on crate feature time only.
Source§

fn year(&self) -> i32

Source§

fn month(&self) -> u8

Source§

fn day(&self) -> u8

Source§

fn hour(&self) -> u8

Source§

fn minute(&self) -> u8

Source§

fn second(&self) -> u8

Source§

fn nanosecond(&self) -> u32

Source§

impl DateTimeParts for PrimitiveDateTime

Available on crate feature time only.
Source§

fn year(&self) -> i32

Source§

fn month(&self) -> u8

Source§

fn day(&self) -> u8

Source§

fn hour(&self) -> u8

Source§

fn minute(&self) -> u8

Source§

fn second(&self) -> u8

Source§

fn nanosecond(&self) -> u32

Source§

impl DateTimeParts for UtcDateTime

Available on crate feature time only.
Source§

fn year(&self) -> i32

Source§

fn month(&self) -> u8

Source§

fn day(&self) -> u8

Source§

fn hour(&self) -> u8

Source§

fn minute(&self) -> u8

Source§

fn second(&self) -> u8

Source§

fn nanosecond(&self) -> u32

Source§

impl DateTimeParts for Zoned

Available on crate feature jiff only.
Source§

fn year(&self) -> i32

Source§

fn month(&self) -> u8

Source§

fn day(&self) -> u8

Source§

fn hour(&self) -> u8

Source§

fn minute(&self) -> u8

Source§

fn second(&self) -> u8

Source§

fn nanosecond(&self) -> u32

Source§

impl<Tz> DateTimeParts for DateTime<Tz>
where Tz: TimeZone, DateTime<Tz>: Ord,

Available on crate feature chrono only.
Source§

fn year(&self) -> i32

Source§

fn month(&self) -> u8

Source§

fn day(&self) -> u8

Source§

fn hour(&self) -> u8

Source§

fn minute(&self) -> u8

Source§

fn second(&self) -> u8

Source§

fn nanosecond(&self) -> u32

Implementors§