[][src]Struct chrono_ext::week::CustomWeek

pub struct CustomWeek { /* fields omitted */ }

Custom week implementation.

PartialOrd and Ord are not implemented, because we do not have a natural ordering for weeks with different specifications. Week start could be recalculated from year, week and specification: it is only stored by convenience for succ, pred, and contains functions.

Methods

impl CustomWeek[src]

pub fn year(&self) -> i32[src]

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

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

Week number in year (0 based).

pub fn week_start(&self) -> NaiveDate[src]

pub fn specification(&self) -> WeekSpecification[src]

pub fn succ(&self) -> CustomWeek[src]

The next week according to the same specification.

pub fn pred(&self) -> CustomWeek[src]

The previous week according to the same specification.

pub fn contains(&self, date: NaiveDate) -> bool[src]

Verify if the given date is in the current week.

pub fn format(&self, fmt: &str) -> String[src]

Very naive week formatting

Formatters are inspired by chrono::format::strftime.

Spec.ExampleDescription
DATE SPECIFIERS:
%Y2001The week year, zero-padded to 4 digits.
%C20The week year divided by 100, zero-padded to 2 digits.
%y01The week year modulo 100, zero-padded to 2 digits.
%W27Week number, zero-padded to 2 digits.
-------------------------------------------------------------------------
use chrono::NaiveDate;
use chrono_ext::{WeekSpecification, CustomWeek};

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

let french_theater_dow_2016_53 = NaiveDate::from_ymd(2017, 1, 3);
let week = french_theater_week.week_from_date(french_theater_dow_2016_53);

assert_eq!("Year 2016", week.format("Year %Y"));
assert_eq!("Year 2016", week.format("Year %C%y"));
assert_eq!("Week 53", week.format("Week %W"));
assert_eq!("S1653", week.format("S%y%W"));

Trait Implementations

impl Clone for CustomWeek[src]

impl Debug for CustomWeek[src]

impl Eq for CustomWeek[src]

impl PartialEq<CustomWeek> for CustomWeek[src]

impl StructuralEq for CustomWeek[src]

impl StructuralPartialEq for CustomWeek[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.