pub struct NaiveWeek { /* private fields */ }
Expand description

A week represented by a NaiveDate and a Weekday which is the first day of the week.

Implementations

Returns a date representing the first day of the week.

Examples
use chrono::{NaiveDate, Weekday};

let date = NaiveDate::from_ymd_opt(2022, 4, 18).unwrap();
let week = date.week(Weekday::Mon);
assert!(week.first_day() <= date);

Returns a date representing the last day of the week.

Examples
use chrono::{NaiveDate, Weekday};

let date = NaiveDate::from_ymd_opt(2022, 4, 18).unwrap();
let week = date.week(Weekday::Mon);
assert!(week.last_day() >= date);

Returns a RangeInclusive<T> representing the whole week bounded by first_day and last_day functions.

Examples
use chrono::{NaiveDate, Weekday};

let date = NaiveDate::from_ymd_opt(2022, 4, 18).unwrap();
let week = date.week(Weekday::Mon);
let days = week.days();
assert!(days.contains(&date));

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.