use powerfmt::smart_display::{FormatterOptions, Metadata, SmartDisplay};
useself::Weekday::*; usecrate::error;
/// 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`. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pubenum Weekday { #[allow(missing_docs)]
Monday, #[allow(missing_docs)]
Tuesday, #[allow(missing_docs)]
Wednesday, #[allow(missing_docs)]
Thursday, #[allow(missing_docs)]
Friday, #[allow(missing_docs)]
Saturday, #[allow(missing_docs)]
Sunday,
}
/// Get the one-indexed number of days from Monday. /// /// ```rust /// # use time::Weekday; /// assert_eq!(Weekday::Monday.number_from_monday(), 1); /// ``` #[doc(alias = "iso_weekday_number")] pubconstfn number_from_monday(self) -> u8 { self.number_days_from_monday() + 1
}
/// Get the one-indexed number of days from Sunday. /// /// ```rust /// # use time::Weekday; /// assert_eq!(Weekday::Monday.number_from_sunday(), 2); /// ``` pubconstfn number_from_sunday(self) -> u8 { self.number_days_from_sunday() + 1
}
/// Get the zero-indexed number of days from Monday. /// /// ```rust /// # use time::Weekday; /// assert_eq!(Weekday::Monday.number_days_from_monday(), 0); /// ``` pubconstfn number_days_from_monday(self) -> u8 { selfas _
}
/// Get the zero-indexed number of days from Sunday. /// /// ```rust /// # use time::Weekday; /// assert_eq!(Weekday::Monday.number_days_from_sunday(), 1); /// ``` pubconstfn number_days_from_sunday(self) -> u8 { matchself {
Monday => 1,
Tuesday => 2,
Wednesday => 3,
Thursday => 4,
Friday => 5,
Saturday => 6,
Sunday => 0,
}
}
}
mod private { #[non_exhaustive] #[derive(Debug, Clone, Copy)] pubstruct WeekdayMetadata;
} use private::WeekdayMetadata;
impl SmartDisplay for Weekday { type Metadata = WeekdayMetadata;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.