pub struct NaiveWeek { /* private fields */ }
Expand description
Implementations§
source§impl NaiveWeek
impl NaiveWeek
sourcepub const fn first_day(&self) -> NaiveDate
pub const fn first_day(&self) -> NaiveDate
Returns a date representing the first day of the week.
§Panics
Panics if the first day of the week happens to fall just out of range of NaiveDate
(more than ca. 262,000 years away from common era).
§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);
sourcepub const fn last_day(&self) -> NaiveDate
pub const fn last_day(&self) -> NaiveDate
Returns a date representing the last day of the week.
§Panics
Panics if the last day of the week happens to fall just out of range of NaiveDate
(more than ca. 262,000 years away from common era).
§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);
sourcepub const fn days(&self) -> RangeInclusive<NaiveDate>
pub const fn days(&self) -> RangeInclusive<NaiveDate>
Returns a RangeInclusive<T>
representing the whole week bounded by
first_day and last_day functions.
§Panics
Panics if the either the first or last day of the week happens to fall just out of range of
NaiveDate
(more than ca. 262,000 years away from common era).
§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§
Auto Trait Implementations§
impl Freeze for NaiveWeek
impl RefUnwindSafe for NaiveWeek
impl Send for NaiveWeek
impl Sync for NaiveWeek
impl Unpin for NaiveWeek
impl UnwindSafe for NaiveWeek
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more