Trait rubedo::chrono::NaiveDateExt

source ·
pub trait NaiveDateExt {
    const MAX_YEAR: i32 = 262_142i32;
    const MIN_YEAR: i32 = -262_143i32;
Show 15 methods // Required methods fn today() -> NaiveDate; fn days_in_month(&self) -> u32; fn days_in_month_opt(year: i32, month: u32) -> Option<u32>; fn days_in_year(&self) -> u32; fn days_in_year_opt(year: i32) -> Option<u32>; fn is_leap_year(&self) -> bool; fn is_leap_year_opt(year: i32) -> Option<bool>; fn start_of_month(&self) -> NaiveDate; fn start_of_month_opt(year: i32, month: u32) -> Option<NaiveDate>; fn end_of_month(&self) -> NaiveDate; fn end_of_month_opt(year: i32, month: u32) -> Option<NaiveDate>; fn start_of_year(&self) -> NaiveDate; fn start_of_year_opt(year: i32) -> Option<NaiveDate>; fn end_of_year(&self) -> NaiveDate; fn end_of_year_opt(year: i32) -> Option<NaiveDate>;
}
Expand description

This trait provides additional functionality to NaiveDate.

Provided Associated Constants§

source

const MAX_YEAR: i32 = 262_142i32

The maximum year that can be represented by a NaiveDate.

source

const MIN_YEAR: i32 = -262_143i32

The minimum year that can be represented by a NaiveDate.

Required Methods§

source

fn today() -> NaiveDate

Returns the current date.

Although this is a static method, it does not return an Option as it cannot fail.

source

fn days_in_month(&self) -> u32

Returns the number of days in the date’s month.

This method operates on &self. For the equivalent method that operates without an instance, see days_in_month_opt().

§See also
source

fn days_in_month_opt(year: i32, month: u32) -> Option<u32>

Returns the number of days in the given month.

This method operates without an instance. For the equivalent method that operates on &self, see days_in_month().

The outcome is wrapped in an Option. If the given year or month is invalid, None is returned.

§See also
source

fn days_in_year(&self) -> u32

Returns the number of days in the date’s year.

This method operates on &self. For the equivalent method that operates without an instance, see days_in_year_opt().

§See also
source

fn days_in_year_opt(year: i32) -> Option<u32>

Returns the number of days in the given year.

This method operates without an instance. For the equivalent method that operates on &self, see days_in_year().

The outcome is wrapped in an Option. If the given year is invalid, None is returned.

§See also
source

fn is_leap_year(&self) -> bool

Returns true if the date’s year is a leap year.

This method operates on &self. For the equivalent method that operates without an instance, see is_leap_year_opt().

§See also
source

fn is_leap_year_opt(year: i32) -> Option<bool>

Returns true if the given year is a leap year.

This method operates without an instance. For the equivalent method that operates on &self, see is_leap_year().

The outcome is wrapped in an Option. If the given year is invalid, None is returned.

§See also
source

fn start_of_month(&self) -> NaiveDate

Returns the date of the first day of the date’s month.

This method operates on &self. For the equivalent method that operates without an instance, see start_of_month_opt().

§See also
source

fn start_of_month_opt(year: i32, month: u32) -> Option<NaiveDate>

Returns the date of the first day of the given month.

This method operates without an instance. For the equivalent method that operates on &self, see start_of_month().

The outcome is wrapped in an Option. If the given year or month is invalid, None is returned.

§See also
source

fn end_of_month(&self) -> NaiveDate

Returns the date of the last day of the date’s month.

This method operates on &self. For the equivalent method that operates without an instance, see end_of_month_opt().

§See also
source

fn end_of_month_opt(year: i32, month: u32) -> Option<NaiveDate>

Returns the date of the last day of the given month.

This method operates without an instance. For the equivalent method that operates on &self, see end_of_month().

The outcome is wrapped in an Option. If the given year or month is invalid, None is returned.

§See also
source

fn start_of_year(&self) -> NaiveDate

Returns the date of the first day of the date’s year.

This method operates on &self. For the equivalent method that operates without an instance, see start_of_year_opt().

§See also
source

fn start_of_year_opt(year: i32) -> Option<NaiveDate>

Returns the date of the first day of the given year.

This method operates without an instance. For the equivalent method that operates on &self, see start_of_year().

The outcome is wrapped in an Option. If the given year is invalid, None is returned.

§See also
source

fn end_of_year(&self) -> NaiveDate

Returns the date of the last day of the date’s year.

This method operates on &self. For the equivalent method that operates without an instance, see end_of_year_opt().

§See also
source

fn end_of_year_opt(year: i32) -> Option<NaiveDate>

Returns the date of the last day of the given year.

This method operates without an instance. For the equivalent method that operates on &self, see end_of_year().

The outcome is wrapped in an Option. If the given year is invalid, None is returned.

§See also

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl NaiveDateExt for NaiveDate

source§

fn today() -> Self

source§

fn days_in_month(&self) -> u32

source§

fn days_in_month_opt(year: i32, month: u32) -> Option<u32>

source§

fn days_in_year(&self) -> u32

source§

fn days_in_year_opt(year: i32) -> Option<u32>

source§

fn is_leap_year(&self) -> bool

source§

fn is_leap_year_opt(year: i32) -> Option<bool>

source§

fn start_of_month(&self) -> Self

source§

fn start_of_month_opt(year: i32, month: u32) -> Option<Self>

source§

fn end_of_month(&self) -> Self

source§

fn end_of_month_opt(year: i32, month: u32) -> Option<Self>

source§

fn start_of_year(&self) -> Self

source§

fn start_of_year_opt(year: i32) -> Option<Self>

source§

fn end_of_year(&self) -> Self

source§

fn end_of_year_opt(year: i32) -> Option<Self>

Implementors§