Struct IsoWeek

pub struct IsoWeek { /* private fields */ }

ISO 8601 week.

This type, combined with Weekday, constitutes the ISO 8601 week date. One can retrieve this type from the existing Datelike types via the Datelike::iso_week method.

Implementations

impl IsoWeek

const fn year(&self) -> i32

Returns the year number for this ISO week.

Example

use chrono::{Datelike, NaiveDate, Weekday};

let d = NaiveDate::from_isoywd_opt(2015, 1, Weekday::Mon).unwrap();
assert_eq!(d.iso_week().year(), 2015);

This year number might not match the calendar year number. Continuing the example...

# use chrono::{NaiveDate, Datelike, Weekday};
# let d = NaiveDate::from_isoywd_opt(2015, 1, Weekday::Mon).unwrap();
assert_eq!(d.year(), 2014);
assert_eq!(d, NaiveDate::from_ymd_opt(2014, 12, 29).unwrap());
const fn week(&self) -> u32

Returns the ISO week number starting from 1.

The return value ranges from 1 to 53. (The last week of year differs by years.)

Example

use chrono::{Datelike, NaiveDate, Weekday};

let d = NaiveDate::from_isoywd_opt(2015, 15, Weekday::Mon).unwrap();
assert_eq!(d.iso_week().week(), 15);
const fn week0(&self) -> u32

Returns the ISO week number starting from 0.

The return value ranges from 0 to 52. (The last week of year differs by years.)

Example

use chrono::{Datelike, NaiveDate, Weekday};

let d = NaiveDate::from_isoywd_opt(2015, 15, Weekday::Mon).unwrap();
assert_eq!(d.iso_week().week0(), 14);

Trait Implementations

impl Clone for IsoWeek

fn clone(&self) -> IsoWeek

impl Copy for IsoWeek

impl Debug for IsoWeek

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Eq for IsoWeek

impl Hash for IsoWeek

fn hash<__H: Hasher>(&self, state: &mut __H)

impl Ord for IsoWeek

fn cmp(&self, other: &IsoWeek) -> Ordering

impl PartialEq for IsoWeek

fn eq(&self, other: &IsoWeek) -> bool

impl PartialOrd for IsoWeek

fn partial_cmp(&self, other: &IsoWeek) -> Option<Ordering>

impl StructuralPartialEq for IsoWeek

Auto Trait Implementations

impl Freeze for IsoWeek

impl RefUnwindSafe for IsoWeek

impl Send for IsoWeek

impl Sync for IsoWeek

impl Unpin for IsoWeek

impl UnsafeUnpin for IsoWeek

impl UnwindSafe for IsoWeek

Blanket Implementations

impl<T> Any for IsoWeek where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for IsoWeek where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for IsoWeek where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for IsoWeek where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for IsoWeek

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for IsoWeek where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for IsoWeek where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for IsoWeek where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for IsoWeek where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>