Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

WeekdayTrait

Fully qualified path: chrono::weekday::WeekdayTrait

pub trait WeekdayTrait

Trait functions

succ

The next day in the week.

w:MonTueWedThuFriSatSun
w.succ():TueWedThuFriSatSunMon

Fully qualified path: chrono::weekday::WeekdayTrait::succ

fn succ(self: @Weekday) -> Weekday

pred

The previous day in the week.

w:MonTueWedThuFriSatSun
w.pred():SunMonTueWedThuFriSat

Fully qualified path: chrono::weekday::WeekdayTrait::pred

fn pred(self: @Weekday) -> Weekday

number_from_monday

Returns a day-of-week number starting from Monday = 1. (ISO 8601 weekday number)

w:MonTueWedThuFriSatSun
w.number_from_monday():1234567

Fully qualified path: chrono::weekday::WeekdayTrait::number_from_monday

fn number_from_monday(self: @Weekday) -> u32

number_from_sunday

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

w:MonTueWedThuFriSatSun
w.number_from_sunday():2345671

Fully qualified path: chrono::weekday::WeekdayTrait::number_from_sunday

fn number_from_sunday(self: @Weekday) -> u32

num_days_from_monday

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

w:MonTueWedThuFriSatSun
w.num_days_from_monday():0123456

Example

 #[cfg(feature = "clock")] {
 use chrono::{Local, Datelike};
// MTWRFSU is occasionally used as a single-letter abbreviation of the weekdays.
// Use `num_days_from_monday` to index into the array.
const MTWRFSU: [char; 7] = ['M', 'T', 'W', 'R', 'F', 'S', 'U'];

let today = Local::now().weekday();
println!("{}", MTWRFSU[today.num_days_from_monday() as usize]);
 }

Fully qualified path: chrono::weekday::WeekdayTrait::num_days_from_monday

fn num_days_from_monday(self: @Weekday) -> u32

num_days_from_sunday

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

w:MonTueWedThuFriSatSun
w.num_days_from_sunday():1234560

Fully qualified path: chrono::weekday::WeekdayTrait::num_days_from_sunday

fn num_days_from_sunday(self: @Weekday) -> u32

days_since

The number of days since the given day.

Examples

use chrono::Weekday::*;
assert_eq!(Mon.days_since(Mon), 0);
assert_eq!(Sun.days_since(Tue), 5);
assert_eq!(Wed.days_since(Sun), 3);

Fully qualified path: chrono::weekday::WeekdayTrait::days_since

fn days_since(self: @Weekday, other: Weekday) -> u32