[][src]Struct doomsday::Doomsday

pub struct Doomsday(pub usize);

Behold the 💥 doomsday of a year

Every year has a single doomsday, for example Doomsday(2020) is Saturday. Additionally, each month has fixed day number for which doomsday lies, for example, in April doomsday is always on the 4th. Given these two peices of information, it's possible to quickly determain the day of any date.

Years before FIRST_LEAP_YEAR aren't supported.

Methods

impl Doomsday[src]

pub fn new(year: usize) -> Doomsday[src]

Create a new doomsday for a given year. TODO: Random or something?

pub fn anchor(&self, month: Month) -> usize[src]

Return the day number, of the anchor doomsday in a given month.

This is the main utility of this crate. Notice how there are really only a few mnemonics to memorize here:

  • 4/4, 6/6, 8/8, 10/10, and 12/12
  • 9 to 5 at 7-Eleven
  • The last day of February (twice)
  • 3 for three years, then 4 on the forth.

These tricks are listed again below for each appropriate month.

pub fn day(&self) -> Day[src]

Return the day of the week which doomsday lies on in a given year.

Trait Implementations

impl Debug for Doomsday[src]

impl Display for Doomsday[src]

The display of doomsday is day, one for every week if you wish.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.