Weekday

Enum Weekday 

Source
#[repr(u8)]
pub enum Weekday { Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7, }
Expand description

§Weekday.

This enum is used by Utc2k to differentiate between calendar weekdays.

§Examples

use utc2k::Weekday;

// The first.
assert_eq!(Weekday::Sunday as u8, 1_u8);
assert_eq!(Weekday::Sunday.as_str(), "Sunday");
assert_eq!(Weekday::Sunday.abbreviation(), "Sun");

// The last.
assert_eq!(Weekday::Saturday as u8, 7_u8);
assert_eq!(Weekday::Saturday.as_str(), "Saturday");
assert_eq!(Weekday::Saturday.abbreviation(), "Sat");

Variants§

§

Sunday = 1

§

Monday = 2

§

Tuesday = 3

§

Wednesday = 4

§

Thursday = 5

§

Friday = 6

§

Saturday = 7

Implementations§

Source§

impl Weekday

Source

pub const ALL: [Self; 7]

§All Weekdays.

This array contains all of the weekdays, in order.

§Examples
for pair in utc2k::Weekday::ALL.windows(2) {
    assert!(pair[0] < pair[1]);
}
Source

pub const fn abbreviation(self) -> &'static str

§As String Slice (Abbreviated).

Return the three-letter abbreviation for a given weekday as a static string slice.

§Examples
use utc2k::Weekday;

assert_eq!(Weekday::Sunday.abbreviation(), "Sun");
assert_eq!(Weekday::Monday.abbreviation(), "Mon");
assert_eq!(Weekday::Tuesday.abbreviation(), "Tue");
assert_eq!(Weekday::Wednesday.abbreviation(), "Wed");
assert_eq!(Weekday::Thursday.abbreviation(), "Thu");
assert_eq!(Weekday::Friday.abbreviation(), "Fri");
assert_eq!(Weekday::Saturday.abbreviation(), "Sat");
Source

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

§As String Slice.

Return the name of a given weekday as a static string slice.

§Examples
use utc2k::Weekday;

assert_eq!(Weekday::Sunday.as_str(), "Sunday");
assert_eq!(Weekday::Monday.as_str(), "Monday");
assert_eq!(Weekday::Tuesday.as_str(), "Tuesday");
assert_eq!(Weekday::Wednesday.as_str(), "Wednesday");
assert_eq!(Weekday::Thursday.as_str(), "Thursday");
assert_eq!(Weekday::Friday.as_str(), "Friday");
assert_eq!(Weekday::Saturday.as_str(), "Saturday");
Source

pub const fn previous(self) -> Self

§Previous Weekday (Wrapping).

Return the previous Weekday.

§Examples
use utc2k::Weekday;

assert_eq!(Weekday::Sunday.previous(), Weekday::Saturday);
assert_eq!(Weekday::Monday.previous(), Weekday::Sunday);
assert_eq!(Weekday::Tuesday.previous(), Weekday::Monday);
assert_eq!(Weekday::Wednesday.previous(), Weekday::Tuesday);
assert_eq!(Weekday::Thursday.previous(), Weekday::Wednesday);
assert_eq!(Weekday::Friday.previous(), Weekday::Thursday);
assert_eq!(Weekday::Saturday.previous(), Weekday::Friday);

// Same as math:
assert_eq!(Weekday::Sunday.previous(), Weekday::Sunday - 1_u8);

// Same as the proper iterator too (provided you skip the first value):
assert_eq!(
    Some(Weekday::Sunday.previous()),
    Weekday::Sunday.into_iter().rev().skip(1).next(),
);
Source

pub const fn next(self) -> Self

§Next Weekday (Wrapping).

Return the next Weekday.

§Examples
use utc2k::Weekday;

assert_eq!(Weekday::Sunday.next(), Weekday::Monday);
assert_eq!(Weekday::Monday.next(), Weekday::Tuesday);
assert_eq!(Weekday::Tuesday.next(), Weekday::Wednesday);
assert_eq!(Weekday::Wednesday.next(), Weekday::Thursday);
assert_eq!(Weekday::Thursday.next(), Weekday::Friday);
assert_eq!(Weekday::Friday.next(), Weekday::Saturday);
assert_eq!(Weekday::Saturday.next(), Weekday::Sunday);

// Same as math:
assert_eq!(Weekday::Sunday.next(), Weekday::Sunday + 1_u8);

// Same as the proper iterator too (provided you skip the first value):
assert_eq!(
    Some(Weekday::Sunday.next()),
    Weekday::Sunday.into_iter().skip(1).next(),
);
Source

pub const fn cmp(a: Self, b: Self) -> Ordering

§Compare Two Weekdays.

Same as Ord/PartialOrd, but constant.

§Examples
use utc2k::Weekday;

assert_eq!(
    Weekday::Sunday.cmp(&Weekday::Sunday),
    Weekday::cmp(Weekday::Sunday, Weekday::Sunday), // Ordering::Equal
);
assert_eq!(
    Weekday::Sunday.cmp(&Weekday::Saturday),
    Weekday::cmp(Weekday::Sunday, Weekday::Saturday), // Ordering::Less
);
assert_eq!(
    Weekday::Saturday.cmp(&Weekday::Sunday),
    Weekday::cmp(Weekday::Saturday, Weekday::Sunday), // Ordering::Greater
);
Source§

impl Weekday

Source

pub fn now() -> Self

§Current Day.

Return the current day of the week (i.e. today).

§Examples.
use utc2k::{Weekday, Utc2k};

assert_eq!(Weekday::now(), Utc2k::now().weekday());
Source

pub fn tomorrow() -> Self

§Tomorrow.

Create a new instance representing one day from now (present time).

§Examples
use utc2k::{Weekday, Utc2k};

assert_eq!(Weekday::tomorrow(), Utc2k::tomorrow().weekday());
Source

pub fn yesterday() -> Self

§Yesterday.

Create a new instance representing one day ago (present time).

§Examples
use utc2k::{Weekday, Utc2k};

assert_eq!(Weekday::yesterday(), Utc2k::yesterday().weekday());
Source§

impl Weekday

Source

pub const fn first_in_month(self, y: u16, m: Month) -> Option<u8>

§Date of First Weekday.

Return the day corresponding to the first occurrence of this weekday in a given year/month.

This will only return None if you pass a bad year and/or month.

§Examples
use utc2k::{Month, Weekday};

// The first Friday in November 2023 was on the 3rd.
assert_eq!(
    Weekday::Friday.first_in_month(2023, Month::November),
    Some(3),
);
Source

pub const fn last_in_month(self, y: u16, m: Month) -> Option<u8>

§Date of Last Weekday.

Return the day corresponding to the last occurrence of this weekday in a given year/month.

This will only return None if you pass a bad year and/or month.

§Examples
use utc2k::{Month, Weekday};

// The last Saturday in Februrary 2020 was the 29th. LEAP!
assert_eq!(
    Weekday::Saturday.last_in_month(2020, Month::February),
    Some(29),
);
Source

pub const fn nth_in_month(self, y: u16, m: Month, n: u8) -> Option<u8>

§Date of Nth Weekday.

Return the day corresponding to the nth occurrence of this weekday in a given year/month, if any. (None is returned if it rolls over.)

§Examples
use utc2k::{Month, Weekday};

let day = Weekday::Monday;

// There are five Mondays in October 2023:
assert_eq!(day.nth_in_month(2023, Month::October, 1), Some(2));
assert_eq!(day.nth_in_month(2023, Month::October, 2), Some(9));
assert_eq!(day.nth_in_month(2023, Month::October, 3), Some(16));
assert_eq!(day.nth_in_month(2023, Month::October, 4), Some(23));
assert_eq!(day.nth_in_month(2023, Month::October, 5), Some(30));

// But no more!
assert_eq!(day.nth_in_month(2023, Month::October, 6), None);

Trait Implementations§

Source§

impl Add<u16> for Weekday

Source§

fn add(self, other: u16) -> Self

§Wrapping u16 Addition.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

let start = Weekday::Sunday;
assert_eq!(start + 0_u16, Weekday::Sunday); // Noop.
assert_eq!(start + 1_u16, Weekday::Monday); 
assert_eq!(start + 2_u16, Weekday::Tuesday); 
assert_eq!(start + 3_u16, Weekday::Wednesday); 
assert_eq!(start + 4_u16, Weekday::Thursday); 
assert_eq!(start + 5_u16, Weekday::Friday); 
assert_eq!(start + 6_u16, Weekday::Saturday); 
assert_eq!(start + 7_u16, Weekday::Sunday); // Wrap.
assert_eq!(start + 8_u16, Weekday::Monday); // Wrap.
assert_eq!(start + 9_u16, Weekday::Tuesday); // Wrap.
// …
Source§

type Output = Weekday

The resulting type after applying the + operator.
Source§

impl Add<u32> for Weekday

Source§

fn add(self, other: u32) -> Self

§Wrapping u32 Addition.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

let start = Weekday::Sunday;
assert_eq!(start + 0_u32, Weekday::Sunday); // Noop.
assert_eq!(start + 1_u32, Weekday::Monday); 
assert_eq!(start + 2_u32, Weekday::Tuesday); 
assert_eq!(start + 3_u32, Weekday::Wednesday); 
assert_eq!(start + 4_u32, Weekday::Thursday); 
assert_eq!(start + 5_u32, Weekday::Friday); 
assert_eq!(start + 6_u32, Weekday::Saturday); 
assert_eq!(start + 7_u32, Weekday::Sunday); // Wrap.
assert_eq!(start + 8_u32, Weekday::Monday); // Wrap.
assert_eq!(start + 9_u32, Weekday::Tuesday); // Wrap.
// …
Source§

type Output = Weekday

The resulting type after applying the + operator.
Source§

impl Add<u64> for Weekday

Source§

fn add(self, other: u64) -> Self

§Wrapping u64 Addition.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

let start = Weekday::Sunday;
assert_eq!(start + 0_u64, Weekday::Sunday); // Noop.
assert_eq!(start + 1_u64, Weekday::Monday); 
assert_eq!(start + 2_u64, Weekday::Tuesday); 
assert_eq!(start + 3_u64, Weekday::Wednesday); 
assert_eq!(start + 4_u64, Weekday::Thursday); 
assert_eq!(start + 5_u64, Weekday::Friday); 
assert_eq!(start + 6_u64, Weekday::Saturday); 
assert_eq!(start + 7_u64, Weekday::Sunday); // Wrap.
assert_eq!(start + 8_u64, Weekday::Monday); // Wrap.
assert_eq!(start + 9_u64, Weekday::Tuesday); // Wrap.
// …
Source§

type Output = Weekday

The resulting type after applying the + operator.
Source§

impl Add<u8> for Weekday

Source§

fn add(self, other: u8) -> Self

§Wrapping u8 Addition.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

let start = Weekday::Sunday;
assert_eq!(start + 0_u8, Weekday::Sunday); // Noop.
assert_eq!(start + 1_u8, Weekday::Monday); 
assert_eq!(start + 2_u8, Weekday::Tuesday); 
assert_eq!(start + 3_u8, Weekday::Wednesday); 
assert_eq!(start + 4_u8, Weekday::Thursday); 
assert_eq!(start + 5_u8, Weekday::Friday); 
assert_eq!(start + 6_u8, Weekday::Saturday); 
assert_eq!(start + 7_u8, Weekday::Sunday); // Wrap.
assert_eq!(start + 8_u8, Weekday::Monday); // Wrap.
assert_eq!(start + 9_u8, Weekday::Tuesday); // Wrap.
// …
Source§

type Output = Weekday

The resulting type after applying the + operator.
Source§

impl Add<usize> for Weekday

Source§

fn add(self, other: usize) -> Self

§Wrapping usize Addition.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

let start = Weekday::Sunday;
assert_eq!(start + 0_usize, Weekday::Sunday); // Noop.
assert_eq!(start + 1_usize, Weekday::Monday); 
assert_eq!(start + 2_usize, Weekday::Tuesday); 
assert_eq!(start + 3_usize, Weekday::Wednesday); 
assert_eq!(start + 4_usize, Weekday::Thursday); 
assert_eq!(start + 5_usize, Weekday::Friday); 
assert_eq!(start + 6_usize, Weekday::Saturday); 
assert_eq!(start + 7_usize, Weekday::Sunday); // Wrap.
assert_eq!(start + 8_usize, Weekday::Monday); // Wrap.
assert_eq!(start + 9_usize, Weekday::Tuesday); // Wrap.
// …
Source§

type Output = Weekday

The resulting type after applying the + operator.
Source§

impl AddAssign<u16> for Weekday

Source§

fn add_assign(&mut self, other: u16)

Performs the += operation. Read more
Source§

impl AddAssign<u32> for Weekday

Source§

fn add_assign(&mut self, other: u32)

Performs the += operation. Read more
Source§

impl AddAssign<u64> for Weekday

Source§

fn add_assign(&mut self, other: u64)

Performs the += operation. Read more
Source§

impl AddAssign<u8> for Weekday

Source§

fn add_assign(&mut self, other: u8)

Performs the += operation. Read more
Source§

impl AddAssign<usize> for Weekday

Source§

fn add_assign(&mut self, other: usize)

Performs the += operation. Read more
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 Borrow<str> for Weekday

Source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
Source§

impl Clone for Weekday

Source§

fn clone(&self) -> Weekday

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Weekday

Source§

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

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

impl Default for Weekday

Source§

fn default() -> Weekday

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Weekday

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

§Deserialize.

Use the optional serde crate feature to enable serialization support.

Source§

impl Display for Weekday

Source§

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

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

impl From<Utc2k> for Weekday

Source§

fn from(src: Utc2k) -> Self

§From Utc2k.

This is equivalent to calling Utc2k::weekday.

§Examples
use utc2k::{Weekday, Utc2k};

let utc = Utc2k::new(2030, 1, 6, 0, 0, 0);
assert_eq!(Weekday::Sunday, Weekday::from(utc));
assert_eq!(Weekday::Sunday, utc.weekday());
Source§

impl From<Weekday> for u16

Source§

fn from(src: Weekday) -> Self

§u16 From Weekday.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

assert_eq!(u16::from(Weekday::Sunday), 1);
assert_eq!(u16::from(Weekday::Monday), 2);
assert_eq!(u16::from(Weekday::Tuesday), 3);
assert_eq!(u16::from(Weekday::Wednesday), 4);
assert_eq!(u16::from(Weekday::Thursday), 5);
assert_eq!(u16::from(Weekday::Friday), 6);
assert_eq!(u16::from(Weekday::Saturday), 7);

// Same as `as` casting.
for v in Weekday::ALL {
    assert_eq!(u16::from(v), v as u16);
}
Source§

impl From<Weekday> for u32

Source§

fn from(src: Weekday) -> Self

§u32 From Weekday.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

assert_eq!(u32::from(Weekday::Sunday), 1);
assert_eq!(u32::from(Weekday::Monday), 2);
assert_eq!(u32::from(Weekday::Tuesday), 3);
assert_eq!(u32::from(Weekday::Wednesday), 4);
assert_eq!(u32::from(Weekday::Thursday), 5);
assert_eq!(u32::from(Weekday::Friday), 6);
assert_eq!(u32::from(Weekday::Saturday), 7);

// Same as `as` casting.
for v in Weekday::ALL {
    assert_eq!(u32::from(v), v as u32);
}
Source§

impl From<Weekday> for u64

Source§

fn from(src: Weekday) -> Self

§u64 From Weekday.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

assert_eq!(u64::from(Weekday::Sunday), 1);
assert_eq!(u64::from(Weekday::Monday), 2);
assert_eq!(u64::from(Weekday::Tuesday), 3);
assert_eq!(u64::from(Weekday::Wednesday), 4);
assert_eq!(u64::from(Weekday::Thursday), 5);
assert_eq!(u64::from(Weekday::Friday), 6);
assert_eq!(u64::from(Weekday::Saturday), 7);

// Same as `as` casting.
for v in Weekday::ALL {
    assert_eq!(u64::from(v), v as u64);
}
Source§

impl From<Weekday> for u8

Source§

fn from(src: Weekday) -> Self

§u8 From Weekday.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

assert_eq!(u8::from(Weekday::Sunday), 1);
assert_eq!(u8::from(Weekday::Monday), 2);
assert_eq!(u8::from(Weekday::Tuesday), 3);
assert_eq!(u8::from(Weekday::Wednesday), 4);
assert_eq!(u8::from(Weekday::Thursday), 5);
assert_eq!(u8::from(Weekday::Friday), 6);
assert_eq!(u8::from(Weekday::Saturday), 7);

// Same as `as` casting.
for v in Weekday::ALL {
    assert_eq!(u8::from(v), v as u8);
}
Source§

impl From<Weekday> for usize

Source§

fn from(src: Weekday) -> Self

§usize From Weekday.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

assert_eq!(usize::from(Weekday::Sunday), 1);
assert_eq!(usize::from(Weekday::Monday), 2);
assert_eq!(usize::from(Weekday::Tuesday), 3);
assert_eq!(usize::from(Weekday::Wednesday), 4);
assert_eq!(usize::from(Weekday::Thursday), 5);
assert_eq!(usize::from(Weekday::Friday), 6);
assert_eq!(usize::from(Weekday::Saturday), 7);

// Same as `as` casting.
for v in Weekday::ALL {
    assert_eq!(usize::from(v), v as usize);
}
Source§

impl From<u16> for Weekday

Source§

fn from(src: u16) -> Self

§Weekday From u16 (Wrapping).

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

assert_eq!(Weekday::from(0_u16), Weekday::Saturday); // Wrap.
assert_eq!(Weekday::from(1_u16), Weekday::Sunday);
assert_eq!(Weekday::from(2_u16), Weekday::Monday);
assert_eq!(Weekday::from(3_u16), Weekday::Tuesday);
assert_eq!(Weekday::from(4_u16), Weekday::Wednesday);
assert_eq!(Weekday::from(5_u16), Weekday::Thursday);
assert_eq!(Weekday::from(6_u16), Weekday::Friday);
assert_eq!(Weekday::from(7_u16), Weekday::Saturday);
assert_eq!(Weekday::from(8_u16), Weekday::Sunday); // Wrap.
assert_eq!(Weekday::from(9_u16), Weekday::Monday); // Wrap.
assert_eq!(Weekday::from(10_u16), Weekday::Tuesday); // Wrap.
// …
Source§

impl From<u32> for Weekday

Source§

fn from(src: u32) -> Self

§Weekday From u32 (Wrapping).

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

assert_eq!(Weekday::from(0_u32), Weekday::Saturday); // Wrap.
assert_eq!(Weekday::from(1_u32), Weekday::Sunday);
assert_eq!(Weekday::from(2_u32), Weekday::Monday);
assert_eq!(Weekday::from(3_u32), Weekday::Tuesday);
assert_eq!(Weekday::from(4_u32), Weekday::Wednesday);
assert_eq!(Weekday::from(5_u32), Weekday::Thursday);
assert_eq!(Weekday::from(6_u32), Weekday::Friday);
assert_eq!(Weekday::from(7_u32), Weekday::Saturday);
assert_eq!(Weekday::from(8_u32), Weekday::Sunday); // Wrap.
assert_eq!(Weekday::from(9_u32), Weekday::Monday); // Wrap.
assert_eq!(Weekday::from(10_u32), Weekday::Tuesday); // Wrap.
// …
Source§

impl From<u64> for Weekday

Source§

fn from(src: u64) -> Self

§Weekday From u64 (Wrapping).

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

assert_eq!(Weekday::from(0_u64), Weekday::Saturday); // Wrap.
assert_eq!(Weekday::from(1_u64), Weekday::Sunday);
assert_eq!(Weekday::from(2_u64), Weekday::Monday);
assert_eq!(Weekday::from(3_u64), Weekday::Tuesday);
assert_eq!(Weekday::from(4_u64), Weekday::Wednesday);
assert_eq!(Weekday::from(5_u64), Weekday::Thursday);
assert_eq!(Weekday::from(6_u64), Weekday::Friday);
assert_eq!(Weekday::from(7_u64), Weekday::Saturday);
assert_eq!(Weekday::from(8_u64), Weekday::Sunday); // Wrap.
assert_eq!(Weekday::from(9_u64), Weekday::Monday); // Wrap.
assert_eq!(Weekday::from(10_u64), Weekday::Tuesday); // Wrap.
// …
Source§

impl From<u8> for Weekday

Source§

fn from(src: u8) -> Self

§Weekday From u8 (Wrapping).

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

assert_eq!(Weekday::from(0_u8), Weekday::Saturday); // Wrap.
assert_eq!(Weekday::from(1_u8), Weekday::Sunday);
assert_eq!(Weekday::from(2_u8), Weekday::Monday);
assert_eq!(Weekday::from(3_u8), Weekday::Tuesday);
assert_eq!(Weekday::from(4_u8), Weekday::Wednesday);
assert_eq!(Weekday::from(5_u8), Weekday::Thursday);
assert_eq!(Weekday::from(6_u8), Weekday::Friday);
assert_eq!(Weekday::from(7_u8), Weekday::Saturday);
assert_eq!(Weekday::from(8_u8), Weekday::Sunday); // Wrap.
assert_eq!(Weekday::from(9_u8), Weekday::Monday); // Wrap.
assert_eq!(Weekday::from(10_u8), Weekday::Tuesday); // Wrap.
// …
Source§

impl From<usize> for Weekday

Source§

fn from(src: usize) -> Self

§Weekday From usize (Wrapping).

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

assert_eq!(Weekday::from(0_usize), Weekday::Saturday); // Wrap.
assert_eq!(Weekday::from(1_usize), Weekday::Sunday);
assert_eq!(Weekday::from(2_usize), Weekday::Monday);
assert_eq!(Weekday::from(3_usize), Weekday::Tuesday);
assert_eq!(Weekday::from(4_usize), Weekday::Wednesday);
assert_eq!(Weekday::from(5_usize), Weekday::Thursday);
assert_eq!(Weekday::from(6_usize), Weekday::Friday);
assert_eq!(Weekday::from(7_usize), Weekday::Saturday);
assert_eq!(Weekday::from(8_usize), Weekday::Sunday); // Wrap.
assert_eq!(Weekday::from(9_usize), Weekday::Monday); // Wrap.
assert_eq!(Weekday::from(10_usize), Weekday::Tuesday); // Wrap.
// …
Source§

impl FromStr for Weekday

Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

§Parse From String.

Parse a Weekday from the first three letters of a string, case-insensitively.

§Examples
use utc2k::Weekday;

for v in Weekday::ALL {
    assert_eq!(v.as_str().parse::<Weekday>(), Ok(v));
    assert_eq!(v.abbreviation().parse::<Weekday>(), Ok(v));
}

// Remember that only the first three letters count!
assert_eq!("Sunlight".parse::<Weekday>(), Ok(Weekday::Sunday));
Source§

type Err = Utc2kError

The associated error which can be returned from parsing.
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 IntoIterator for Weekday

Source§

fn into_iter(self) -> Self::IntoIter

§Endless Weekday Iterator.

Return an iterator that will cycle endlessly through the weekdays, in order, forward or backward, starting with self.

§Examples
use utc2k::Weekday;

let mut iter = Weekday::Sunday.into_iter();
assert_eq!(iter.next(), Some(Weekday::Sunday)); 
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)); // Wrap.
assert_eq!(iter.next(), Some(Weekday::Monday)); // Wrap.
assert_eq!(iter.next(), Some(Weekday::Tuesday)); // Wrap.
// …

// Or like Ginger, backwards and in high heels.
let mut iter = Weekday::Saturday.into_iter().rev();
assert_eq!(iter.next(), Some(Weekday::Saturday)); 
assert_eq!(iter.next(), Some(Weekday::Friday)); 
assert_eq!(iter.next(), Some(Weekday::Thursday)); 
assert_eq!(iter.next(), Some(Weekday::Wednesday)); 
assert_eq!(iter.next(), Some(Weekday::Tuesday)); 
assert_eq!(iter.next(), Some(Weekday::Monday)); 
assert_eq!(iter.next(), Some(Weekday::Sunday)); 
assert_eq!(iter.next(), Some(Weekday::Saturday)); // Wrap.
assert_eq!(iter.next(), Some(Weekday::Friday)); // Wrap.
assert_eq!(iter.next(), Some(Weekday::Thursday)); // Wrap.
// …
Source§

type Item = Weekday

The type of the elements being iterated over.
Source§

type IntoIter = RepeatingWeekdayIter

Which kind of iterator are we turning this into?
Source§

impl Ord for Weekday

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<Weekday> for u16

Source§

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

§u16/Weekday Equality.
use utc2k::Weekday;

assert_eq!(1_u16, Weekday::Sunday);
assert_eq!(2_u16, Weekday::Monday);
assert_eq!(3_u16, Weekday::Tuesday);
assert_eq!(4_u16, Weekday::Wednesday);
assert_eq!(5_u16, Weekday::Thursday);
assert_eq!(6_u16, Weekday::Friday);
assert_eq!(7_u16, Weekday::Saturday);

// Nope. assert_ne!(u16::MIN, Weekday::Sunday);

1.0.0 · 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 PartialEq<Weekday> for u32

Source§

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

§u32/Weekday Equality.
use utc2k::Weekday;

assert_eq!(1_u32, Weekday::Sunday);
assert_eq!(2_u32, Weekday::Monday);
assert_eq!(3_u32, Weekday::Tuesday);
assert_eq!(4_u32, Weekday::Wednesday);
assert_eq!(5_u32, Weekday::Thursday);
assert_eq!(6_u32, Weekday::Friday);
assert_eq!(7_u32, Weekday::Saturday);

// Nope. assert_ne!(u32::MIN, Weekday::Sunday);

1.0.0 · 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 PartialEq<Weekday> for u64

Source§

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

§u64/Weekday Equality.
use utc2k::Weekday;

assert_eq!(1_u64, Weekday::Sunday);
assert_eq!(2_u64, Weekday::Monday);
assert_eq!(3_u64, Weekday::Tuesday);
assert_eq!(4_u64, Weekday::Wednesday);
assert_eq!(5_u64, Weekday::Thursday);
assert_eq!(6_u64, Weekday::Friday);
assert_eq!(7_u64, Weekday::Saturday);

// Nope. assert_ne!(u64::MIN, Weekday::Sunday);

1.0.0 · 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 PartialEq<Weekday> for u8

Source§

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

§u8/Weekday Equality.
use utc2k::Weekday;

assert_eq!(1_u8, Weekday::Sunday);
assert_eq!(2_u8, Weekday::Monday);
assert_eq!(3_u8, Weekday::Tuesday);
assert_eq!(4_u8, Weekday::Wednesday);
assert_eq!(5_u8, Weekday::Thursday);
assert_eq!(6_u8, Weekday::Friday);
assert_eq!(7_u8, Weekday::Saturday);

// Nope. assert_ne!(u8::MIN, Weekday::Sunday);

1.0.0 · 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 PartialEq<Weekday> for usize

Source§

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

§usize/Weekday Equality.
use utc2k::Weekday;

assert_eq!(1_usize, Weekday::Sunday);
assert_eq!(2_usize, Weekday::Monday);
assert_eq!(3_usize, Weekday::Tuesday);
assert_eq!(4_usize, Weekday::Wednesday);
assert_eq!(5_usize, Weekday::Thursday);
assert_eq!(6_usize, Weekday::Friday);
assert_eq!(7_usize, Weekday::Saturday);

// Nope. assert_ne!(usize::MIN, Weekday::Sunday);

1.0.0 · 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 PartialEq<u16> for Weekday

Source§

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

§Weekday/u16 Equality.
use utc2k::Weekday;

assert_eq!(Weekday::Sunday, 1_u16);
assert_eq!(Weekday::Monday, 2_u16);
assert_eq!(Weekday::Tuesday, 3_u16);
assert_eq!(Weekday::Wednesday, 4_u16);
assert_eq!(Weekday::Thursday, 5_u16);
assert_eq!(Weekday::Friday, 6_u16);
assert_eq!(Weekday::Saturday, 7_u16);

// Nope.
assert_ne!(Weekday::Sunday, u16::MIN);
1.0.0 · 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 PartialEq<u32> for Weekday

Source§

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

§Weekday/u32 Equality.
use utc2k::Weekday;

assert_eq!(Weekday::Sunday, 1_u32);
assert_eq!(Weekday::Monday, 2_u32);
assert_eq!(Weekday::Tuesday, 3_u32);
assert_eq!(Weekday::Wednesday, 4_u32);
assert_eq!(Weekday::Thursday, 5_u32);
assert_eq!(Weekday::Friday, 6_u32);
assert_eq!(Weekday::Saturday, 7_u32);

// Nope.
assert_ne!(Weekday::Sunday, u32::MIN);
1.0.0 · 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 PartialEq<u64> for Weekday

Source§

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

§Weekday/u64 Equality.
use utc2k::Weekday;

assert_eq!(Weekday::Sunday, 1_u64);
assert_eq!(Weekday::Monday, 2_u64);
assert_eq!(Weekday::Tuesday, 3_u64);
assert_eq!(Weekday::Wednesday, 4_u64);
assert_eq!(Weekday::Thursday, 5_u64);
assert_eq!(Weekday::Friday, 6_u64);
assert_eq!(Weekday::Saturday, 7_u64);

// Nope.
assert_ne!(Weekday::Sunday, u64::MIN);
1.0.0 · 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 PartialEq<u8> for Weekday

Source§

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

§Weekday/u8 Equality.
use utc2k::Weekday;

assert_eq!(Weekday::Sunday, 1_u8);
assert_eq!(Weekday::Monday, 2_u8);
assert_eq!(Weekday::Tuesday, 3_u8);
assert_eq!(Weekday::Wednesday, 4_u8);
assert_eq!(Weekday::Thursday, 5_u8);
assert_eq!(Weekday::Friday, 6_u8);
assert_eq!(Weekday::Saturday, 7_u8);

// Nope.
assert_ne!(Weekday::Sunday, u8::MIN);
1.0.0 · 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 PartialEq<usize> for Weekday

Source§

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

§Weekday/usize Equality.
use utc2k::Weekday;

assert_eq!(Weekday::Sunday, 1_usize);
assert_eq!(Weekday::Monday, 2_usize);
assert_eq!(Weekday::Tuesday, 3_usize);
assert_eq!(Weekday::Wednesday, 4_usize);
assert_eq!(Weekday::Thursday, 5_usize);
assert_eq!(Weekday::Friday, 6_usize);
assert_eq!(Weekday::Saturday, 7_usize);

// Nope.
assert_ne!(Weekday::Sunday, usize::MIN);
1.0.0 · 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 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 · 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 PartialOrd for Weekday

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Weekday

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

§Serialize.

Use the optional serde crate feature to enable serialization support.

Source§

impl Sub<u16> for Weekday

Source§

fn sub(self, other: u16) -> Self

§Wrapping u16 Subtraction.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

let start = Weekday::Sunday;
assert_eq!(start - 0_u16, Weekday::Sunday); // Noop.
assert_eq!(start - 1_u16, Weekday::Saturday); 
assert_eq!(start - 2_u16, Weekday::Friday); 
assert_eq!(start - 3_u16, Weekday::Thursday); 
assert_eq!(start - 4_u16, Weekday::Wednesday); 
assert_eq!(start - 5_u16, Weekday::Tuesday); 
assert_eq!(start - 6_u16, Weekday::Monday); 
assert_eq!(start - 7_u16, Weekday::Sunday); // Wrap.
assert_eq!(start - 8_u16, Weekday::Saturday); // Wrap.
assert_eq!(start - 9_u16, Weekday::Friday); // Wrap.
// …
Source§

type Output = Weekday

The resulting type after applying the - operator.
Source§

impl Sub<u32> for Weekday

Source§

fn sub(self, other: u32) -> Self

§Wrapping u32 Subtraction.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

let start = Weekday::Sunday;
assert_eq!(start - 0_u32, Weekday::Sunday); // Noop.
assert_eq!(start - 1_u32, Weekday::Saturday); 
assert_eq!(start - 2_u32, Weekday::Friday); 
assert_eq!(start - 3_u32, Weekday::Thursday); 
assert_eq!(start - 4_u32, Weekday::Wednesday); 
assert_eq!(start - 5_u32, Weekday::Tuesday); 
assert_eq!(start - 6_u32, Weekday::Monday); 
assert_eq!(start - 7_u32, Weekday::Sunday); // Wrap.
assert_eq!(start - 8_u32, Weekday::Saturday); // Wrap.
assert_eq!(start - 9_u32, Weekday::Friday); // Wrap.
// …
Source§

type Output = Weekday

The resulting type after applying the - operator.
Source§

impl Sub<u64> for Weekday

Source§

fn sub(self, other: u64) -> Self

§Wrapping u64 Subtraction.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

let start = Weekday::Sunday;
assert_eq!(start - 0_u64, Weekday::Sunday); // Noop.
assert_eq!(start - 1_u64, Weekday::Saturday); 
assert_eq!(start - 2_u64, Weekday::Friday); 
assert_eq!(start - 3_u64, Weekday::Thursday); 
assert_eq!(start - 4_u64, Weekday::Wednesday); 
assert_eq!(start - 5_u64, Weekday::Tuesday); 
assert_eq!(start - 6_u64, Weekday::Monday); 
assert_eq!(start - 7_u64, Weekday::Sunday); // Wrap.
assert_eq!(start - 8_u64, Weekday::Saturday); // Wrap.
assert_eq!(start - 9_u64, Weekday::Friday); // Wrap.
// …
Source§

type Output = Weekday

The resulting type after applying the - operator.
Source§

impl Sub<u8> for Weekday

Source§

fn sub(self, other: u8) -> Self

§Wrapping u8 Subtraction.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

let start = Weekday::Sunday;
assert_eq!(start - 0_u8, Weekday::Sunday); // Noop.
assert_eq!(start - 1_u8, Weekday::Saturday); 
assert_eq!(start - 2_u8, Weekday::Friday); 
assert_eq!(start - 3_u8, Weekday::Thursday); 
assert_eq!(start - 4_u8, Weekday::Wednesday); 
assert_eq!(start - 5_u8, Weekday::Tuesday); 
assert_eq!(start - 6_u8, Weekday::Monday); 
assert_eq!(start - 7_u8, Weekday::Sunday); // Wrap.
assert_eq!(start - 8_u8, Weekday::Saturday); // Wrap.
assert_eq!(start - 9_u8, Weekday::Friday); // Wrap.
// …
Source§

type Output = Weekday

The resulting type after applying the - operator.
Source§

impl Sub<usize> for Weekday

Source§

fn sub(self, other: usize) -> Self

§Wrapping usize Subtraction.

Weekdays range from 1..=7, starting with Sunday.

§Examples
use utc2k::Weekday;

let start = Weekday::Sunday;
assert_eq!(start - 0_usize, Weekday::Sunday); // Noop.
assert_eq!(start - 1_usize, Weekday::Saturday); 
assert_eq!(start - 2_usize, Weekday::Friday); 
assert_eq!(start - 3_usize, Weekday::Thursday); 
assert_eq!(start - 4_usize, Weekday::Wednesday); 
assert_eq!(start - 5_usize, Weekday::Tuesday); 
assert_eq!(start - 6_usize, Weekday::Monday); 
assert_eq!(start - 7_usize, Weekday::Sunday); // Wrap.
assert_eq!(start - 8_usize, Weekday::Saturday); // Wrap.
assert_eq!(start - 9_usize, Weekday::Friday); // Wrap.
// …
Source§

type Output = Weekday

The resulting type after applying the - operator.
Source§

impl SubAssign<u16> for Weekday

Source§

fn sub_assign(&mut self, other: u16)

Performs the -= operation. Read more
Source§

impl SubAssign<u32> for Weekday

Source§

fn sub_assign(&mut self, other: u32)

Performs the -= operation. Read more
Source§

impl SubAssign<u64> for Weekday

Source§

fn sub_assign(&mut self, other: u64)

Performs the -= operation. Read more
Source§

impl SubAssign<u8> for Weekday

Source§

fn sub_assign(&mut self, other: u8)

Performs the -= operation. Read more
Source§

impl SubAssign<usize> for Weekday

Source§

fn sub_assign(&mut self, other: usize)

Performs the -= operation. Read more
Source§

impl TryFrom<&[u8]> for Weekday

Source§

fn try_from(src: &[u8]) -> Result<Self, Self::Error>

§From Byte Slice.

Parse a Weekday from the first three bytes of a slice, case-insensitively.

§Examples
use utc2k::Weekday;

// Case doesn't matter.
assert_eq!(
    Weekday::try_from(b"monday".as_slice()),
    Ok(Weekday::Monday),
);
assert_eq!(
    Weekday::try_from(b"Monday".as_slice()),
    Ok(Weekday::Monday),
);
assert_eq!(
    Weekday::try_from(b"MONDAY".as_slice()),
    Ok(Weekday::Monday),
);

// Only the first three bytes are actually inspected.
assert_eq!(
    Weekday::try_from(b"Mon".as_slice()),
    Ok(Weekday::Monday),
);
assert_eq!(
    Weekday::try_from(b"money".as_slice()), // Close enough!
    Ok(Weekday::Monday),
);

// Wrong is wrong.
assert!(Weekday::try_from(b"moonday".as_slice()).is_err());
Source§

type Error = Utc2kError

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

impl TryFrom<&Box<str>> for Weekday

Source§

type Error = Utc2kError

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

fn try_from(src: &Box<str>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&Cow<'_, str>> for Weekday

Source§

type Error = Utc2kError

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

fn try_from(src: &Cow<'_, str>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&String> for Weekday

Source§

type Error = Utc2kError

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

fn try_from(src: &String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&str> for Weekday

Source§

type Error = Utc2kError

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

fn try_from(src: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Box<str>> for Weekday

Source§

type Error = Utc2kError

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

fn try_from(src: Box<str>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Cow<'_, str>> for Weekday

Source§

type Error = Utc2kError

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

fn try_from(src: Cow<'_, str>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<String> for Weekday

Source§

type Error = Utc2kError

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

fn try_from(src: String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Weekday

Source§

impl Eq for Weekday

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,