Skip to content

Weekday

A day of the week, Monday first (ISO 8601).

use helpers4::date::Weekday;

Cargo feature date (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features date

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.6", default-features = false, features = ["date"] }
pub enum Weekday {
    /// Monday, ISO day 1.
    Monday,
    /// Tuesday, ISO day 2.
    Tuesday,
    /// Wednesday, ISO day 3.
    Wednesday,
    /// Thursday, ISO day 4.
    Thursday,
    /// Friday, ISO day 5.
    Friday,
    /// Saturday, ISO day 6.
    Saturday,
    /// Sunday, ISO day 7.
    Sunday,
}
use helpers4::date::{Date, Weekday};

let day = Date::new(2024, 1, 1)?.weekday();
assert_eq!(day, Weekday::Monday);
assert_eq!(day.name(), "Monday");
assert_eq!(day.iso_number(), 1);
assert!(!day.is_weekend());
pub fn name(self) -> &'static str

The English name, such as "Monday".

Returns

&'static str — The capitalized name of the day.

pub fn iso_number(self) -> u8

The ISO 8601 number of the day: Monday is 1, Sunday is 7.

Returns

u8 — A number from 1 to 7.

pub fn is_weekend(self) -> bool

Whether the day is a Saturday or a Sunday.

Returns

booltrue for the weekend.

src/date/weekday.rs