pub struct NaiveWeek { /* private fields */ }
Expand description
Implementations§
source§impl NaiveWeek
impl NaiveWeek
sourcepub fn first_day(&self) -> NaiveDate
pub fn first_day(&self) -> NaiveDate
Returns a date representing the first day of the week.
Examples
use chrono::{NaiveDate, Weekday};
let date = NaiveDate::from_ymd(2022, 4, 18);
let week = date.week(Weekday::Mon);
assert!(week.first_day() <= date);
sourcepub fn last_day(&self) -> NaiveDate
pub fn last_day(&self) -> NaiveDate
Returns a date representing the last day of the week.
Examples
use chrono::{NaiveDate, Weekday};
let date = NaiveDate::from_ymd(2022, 4, 18);
let week = date.week(Weekday::Mon);
assert!(week.last_day() >= date);
sourcepub fn days(&self) -> RangeInclusive<NaiveDate>
pub fn days(&self) -> RangeInclusive<NaiveDate>
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(2022, 4, 18);
let week = date.week(Weekday::Mon);
let days = week.days();
assert!(days.contains(&date));