Enum Weekday

#[repr(u8)]
pub enum Weekday

Days of the week.

As order is dependent on context (Sunday could be either two days after or five days before Friday), this type does not implement PartialOrd or Ord.

Variants

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Implementations

impl Weekday

const fn previous(self) -> Self

Get the previous weekday.

# use time::Weekday;
assert_eq!(Weekday::Tuesday.previous(), Weekday::Monday);
const fn next(self) -> Self

Get the next weekday.

# use time::Weekday;
assert_eq!(Weekday::Monday.next(), Weekday::Tuesday);
const fn nth_next(self, n: u8) -> Self

Get n-th next day.

# use time::Weekday;
assert_eq!(Weekday::Monday.nth_next(1), Weekday::Tuesday);
assert_eq!(Weekday::Sunday.nth_next(10), Weekday::Wednesday);
const fn nth_prev(self, n: u8) -> Self

Get n-th previous day.

# use time::Weekday;
assert_eq!(Weekday::Monday.nth_prev(1), Weekday::Sunday);
assert_eq!(Weekday::Sunday.nth_prev(10), Weekday::Thursday);
const fn number_from_monday(self) -> u8

Get the one-indexed number of days from Monday.

# use time::Weekday;
assert_eq!(Weekday::Monday.number_from_monday(), 1);
const fn number_from_sunday(self) -> u8

Get the one-indexed number of days from Sunday.

# use time::Weekday;
assert_eq!(Weekday::Monday.number_from_sunday(), 2);
const fn number_days_from_monday(self) -> u8

Get the zero-indexed number of days from Monday.

# use time::Weekday;
assert_eq!(Weekday::Monday.number_days_from_monday(), 0);
const fn number_days_from_sunday(self) -> u8

Get the zero-indexed number of days from Sunday.

# use time::Weekday;
assert_eq!(Weekday::Monday.number_days_from_sunday(), 1);
const fn iter_from(start: Self) -> WeekdayIter

Create an infinite iterator starting at this weekday.

# use time::Weekday;
let mut iter = Weekday::iter_from(Weekday::Monday);
assert_eq!(iter.next(), Some(Weekday::Monday));
assert_eq!(iter.next(), Some(Weekday::Tuesday));
assert_eq!(iter.next(), Some(Weekday::Wednesday));
assert_eq!(iter.next(), Some(Weekday::Thursday));
assert_eq!(iter.next(), Some(Weekday::Friday));
assert_eq!(iter.next(), Some(Weekday::Saturday));
assert_eq!(iter.next(), Some(Weekday::Sunday));
assert_eq!(iter.next(), Some(Weekday::Monday));
// … continuing forever

Trait Implementations

impl Clone for Weekday

fn clone(&self) -> Self

impl Copy for Weekday

impl Debug for Weekday

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

impl Display for Weekday

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

impl Eq for Weekday

impl FromStr for Weekday

type Err = InvalidVariant;
fn from_str(s: &str) -> Result<Self, Self::Err>

impl Hash for Weekday

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

impl PartialEq for Weekday

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

impl SmartDisplay for Weekday

type Metadata = ();
fn metadata(&self, FormatterOptions) -> Metadata<'_, Self>
fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl StructuralPartialEq for Weekday

Auto Trait Implementations

impl Freeze for Weekday

impl RefUnwindSafe for Weekday

impl Send for Weekday

impl Sync for Weekday

impl Unpin for Weekday

impl UnsafeUnpin for Weekday

impl UnwindSafe for Weekday

Blanket Implementations

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

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

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

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

impl<T> From<T> for Weekday

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

impl<T> ToString for Weekday where T: Display + ?Sized,

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

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

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