[][src]Struct chrono_ext::week::WeekSpecification

pub struct WeekSpecification { /* fields omitted */ }

Methods

impl WeekSpecification[src]

pub fn new(
    first_day: Weekday,
    min_days_in_first_week: u32
) -> Result<WeekSpecification, Error>
[src]

pub fn sunday_start() -> WeekSpecification[src]

pub fn iso_week() -> WeekSpecification[src]

pub fn french_theater_week() -> WeekSpecification[src]

pub fn first_day(&self) -> Weekday[src]

pub fn min_days_in_first_week(&self) -> u32[src]

pub fn first_day_of_week_based_year(&self, year: i32) -> NaiveDate[src]

Find the first day of week based year for current specification.

use chrono::NaiveDate;
use chrono_ext::WeekSpecification;

let iso_week: WeekSpecification = WeekSpecification::iso_week();
let french_theater_week: WeekSpecification = WeekSpecification::french_theater_week();

assert_eq!(NaiveDate::from_ymd(2018, 12, 31), iso_week.first_day_of_week_based_year(2019));
assert_eq!(NaiveDate::from_ymd(2019, 1, 2), french_theater_week.first_day_of_week_based_year(2019));

pub fn last_day_of_week_based_year(&self, year: i32) -> NaiveDate[src]

Find the last day of week based year for current specification.

use chrono::NaiveDate;
use chrono_ext::WeekSpecification;

let iso_week: WeekSpecification = WeekSpecification::iso_week();
let french_theater_week: WeekSpecification = WeekSpecification::french_theater_week();

assert_eq!(NaiveDate::from_ymd(2019, 12, 29), iso_week.last_day_of_week_based_year(2019));
assert_eq!(NaiveDate::from_ymd(2019, 12, 31), french_theater_week.last_day_of_week_based_year(2019));

pub fn num_weeks(&self, year: i32) -> u32[src]

Count year weeks for current week specification.

use chrono_ext::WeekSpecification;

let iso_week: WeekSpecification = WeekSpecification::iso_week();
let french_theater_week: WeekSpecification = WeekSpecification::french_theater_week();

assert_eq!(52, iso_week.num_weeks(2019));
assert_eq!(52, french_theater_week.num_weeks(2019));
assert_eq!(53, french_theater_week.num_weeks(2016));

pub fn num_days_from_first_dow(&self, day: Weekday) -> u32[src]

Number of days from current week (from 0 to 6).

use chrono::Weekday;
use chrono_ext::WeekSpecification;

let french_theater_week: WeekSpecification = WeekSpecification::french_theater_week();

assert_eq!(0, french_theater_week.num_days_from_first_dow(Weekday::Wed));
assert_eq!(6, french_theater_week.num_days_from_first_dow(Weekday::Tue));

pub fn number_from_first_dow(&self, day: Weekday) -> u32[src]

Number of the day from current week specification (from 1 to 7).

use chrono::Weekday;
use chrono_ext::WeekSpecification;

let french_theater_week: WeekSpecification = WeekSpecification::french_theater_week();

assert_eq!(1, french_theater_week.number_from_first_dow(Weekday::Wed));
assert_eq!(7, french_theater_week.number_from_first_dow(Weekday::Tue));

pub fn week_from_date(&self, date: NaiveDate) -> CustomWeek[src]

Compute week for a given date, according current specification.

use chrono::NaiveDate;
use chrono_ext::{WeekSpecification, CustomWeek};

let french_theater_week: WeekSpecification = WeekSpecification::french_theater_week();

let french_theater_first_dow_2016_53 = NaiveDate::from_ymd(2016, 12, 28);
let french_theater_last_dow_2016_53 = NaiveDate::from_ymd(2017, 1, 3);

let week = french_theater_week.week_from_date(french_theater_last_dow_2016_53);

assert_eq!(2016, week.year());
assert_eq!(53, week.week());
assert_eq!(52, week.week0());
assert_eq!(french_theater_first_dow_2016_53, week.week_start());
assert_eq!(french_theater_week, week.specification());

pub fn week_from_yw(&self, year: i32, week: u32) -> Result<CustomWeek, Error>[src]

Compute week for a given year/week number, according current specification.

use chrono::NaiveDate;
use chrono_ext::{WeekSpecification, CustomWeek};

let french_theater_week: WeekSpecification = WeekSpecification::french_theater_week();

let french_theater_first_dow_2016_53 = NaiveDate::from_ymd(2016, 12, 28);

let week = french_theater_week.week_from_yw(2016, 53).unwrap();

assert_eq!(2016, week.year());
assert_eq!(53, week.week());
assert_eq!(52, week.week0());
assert_eq!(french_theater_first_dow_2016_53, week.week_start());
assert_eq!(french_theater_week, week.specification());

Trait Implementations

impl Clone for WeekSpecification[src]

impl Copy for WeekSpecification[src]

impl Debug for WeekSpecification[src]

impl Eq for WeekSpecification[src]

impl PartialEq<WeekSpecification> for WeekSpecification[src]

impl StructuralEq for WeekSpecification[src]

impl StructuralPartialEq for WeekSpecification[src]

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.