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§
Required Methods§
sourcefn today() -> NaiveDate
fn today() -> NaiveDate
Returns the current date.
Although this is a static method, it does not return an Option
as it
cannot fail.
sourcefn days_in_month(&self) -> u32
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
sourcefn days_in_month_opt(year: i32, month: u32) -> Option<u32>
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
sourcefn days_in_year(&self) -> u32
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
sourcefn days_in_year_opt(year: i32) -> Option<u32>
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
sourcefn is_leap_year(&self) -> bool
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
sourcefn is_leap_year_opt(year: i32) -> Option<bool>
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
sourcefn start_of_month(&self) -> NaiveDate
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
sourcefn start_of_month_opt(year: i32, month: u32) -> Option<NaiveDate>
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
sourcefn end_of_month(&self) -> NaiveDate
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
sourcefn end_of_month_opt(year: i32, month: u32) -> Option<NaiveDate>
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
sourcefn start_of_year(&self) -> NaiveDate
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
sourcefn start_of_year_opt(year: i32) -> Option<NaiveDate>
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
sourcefn end_of_year(&self) -> NaiveDate
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
sourcefn end_of_year_opt(year: i32) -> Option<NaiveDate>
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.