[−][src]Struct chrono_ext::week::CustomWeek
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. | Example | Description |
---|---|---|
DATE SPECIFIERS: | ||
%Y | 2001 | The week year, zero-padded to 4 digits. |
%C | 20 | The week year divided by 100, zero-padded to 2 digits. |
%y | 01 | The week year modulo 100, zero-padded to 2 digits. |
%W | 27 | Week 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]
fn clone(&self) -> CustomWeek
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for CustomWeek
[src]
impl Eq for CustomWeek
[src]
impl PartialEq<CustomWeek> for CustomWeek
[src]
fn eq(&self, other: &CustomWeek) -> bool
[src]
fn ne(&self, other: &CustomWeek) -> bool
[src]
impl StructuralEq for CustomWeek
[src]
impl StructuralPartialEq for CustomWeek
[src]
Auto Trait Implementations
impl RefUnwindSafe for CustomWeek
impl Send for CustomWeek
impl Sync for CustomWeek
impl Unpin for CustomWeek
impl UnwindSafe for CustomWeek
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,