Skip to main content

Weekday

Enum Weekday 

Source
#[repr(u8)]
pub enum Weekday { Mon = 1, Tue = 2, Wed = 3, Thu = 4, Fri = 5, Sat = 6, Sun = 7, }
Expand description

Day of the week starting from Monday = 1 (ISO 8601).

The ordinal value of 0 is not being used by common RTC chips. This place can be used to re-map Sunday to 0 in order to obtain a week starting from Sunday.

PartialOrd isn’t implemented on purpose because weekdays are usually used in a cyclic manner.

Variants§

§

Mon = 1

Monday.

§

Tue = 2

Tuesday.

§

Wed = 3

Wednesday.

§

Thu = 4

Thursday.

§

Fri = 5

Friday.

§

Sat = 6

Saturday.

§

Sun = 7

Sunday.

Implementations§

Source§

impl Weekday

Source

pub const MON_NUM: u8 = 1

the numeric code being used for Monday.

Source

pub const TUE_NUM: u8 = 2

the numeric code being used for Tuesday.

Source

pub const WED_NUM: u8 = 3

the numeric code being used for Wednesday.

Source

pub const THU_NUM: u8 = 4

the numeric code being used for Thursday.

Source

pub const FRI_NUM: u8 = 5

the numeric code being used for Friday.

Source

pub const SAT_NUM: u8 = 6

the numeric code being used for Saturday.

Source

pub const SUN_NUM: u8 = 7

the numeric code being used for Sunday.

Source

pub const MON: &str = "Mon"

the short name of Monday in English.

Source

pub const TUE: &str = "Tue"

the short name of Tuesday in English.

Source

pub const WED: &str = "Wed"

the short name of Wednesday in English.

Source

pub const THU: &str = "Thu"

the short name of Thursday in English.

Source

pub const FRI: &str = "Fri"

the short name of Friday in English.

Source

pub const SAT: &str = "Sat"

the short name of Saturday in English.

Source

pub const SUN: &str = "Sun"

the short name of Sunday in English.

Source

pub fn num_days_from_monday(self) -> u8

Returns a day-of-week number starting from Monday = 0.

Source

pub fn number_from_monday(self) -> u8

Returns a day-of-week number starting from Monday = 1.

Source

pub fn num_days_from_sunday(self) -> u8

Returns a day-of-week number starting from Sunday = 0.

Source

pub fn number_from_sunday(self) -> u8

Returns a day-of-week number starting from Sunday = 1.

Source

pub fn as_str(self) -> &'static str

Return the weekday’s short name in English.

The returned string is guaranteed to be 3 characters long.

Trait Implementations§

Source§

impl AsRef<str> for Weekday

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Weekday

Source§

fn clone(&self) -> Weekday

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Weekday

Source§

impl Debug for Weekday

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Weekday

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Weekday

Source§

impl From<u8> for Weekday

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl Hash for Weekday

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Weekday

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Weekday

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.