Struct whatwg_datetime::YearWeek
source · pub struct YearWeek { /* private fields */ }
Expand description
A week date consisting of a year and a week number.
Examples
use whatwg_datetime::{parse_week, YearWeek};
assert_eq!(parse_week("2011-W47"), YearWeek::new_opt(2011, 47));
Implementations§
source§impl YearWeek
impl YearWeek
sourcepub fn new_opt(year: i32, week: u32) -> Option<Self>
pub fn new_opt(year: i32, week: u32) -> Option<Self>
Creates a new YearWeek
from a year and a week number.
This asserts that the year is greater than 0 and that the week number is in the valid range for the year. Specifically, the week number must be between 1 and the number of weeks in the year, inclusive.
The number of weeks in a year is described by the algorithm in [WHATWG HTML Standard § 2.3.5.8 Weeks][whatwg-html-weeks].
Examples
use whatwg_datetime::YearWeek;
assert!(YearWeek::new_opt(2004, 53).is_some());
assert!(YearWeek::new_opt(2011, 47).is_some());
assert!(YearWeek::new_opt(2011, 53).is_none()); // 2011 only has 52 weeks
assert!(YearWeek::new_opt(1952, 0).is_none()); // Week number must be at least 1
assert!(YearWeek::new_opt(0, 1).is_none()); // Year number must be greater than 0
Trait Implementations§
source§impl PartialEq<YearWeek> for YearWeek
impl PartialEq<YearWeek> for YearWeek
impl Copy for YearWeek
impl Eq for YearWeek
impl StructuralEq for YearWeek
impl StructuralPartialEq for YearWeek
Auto Trait Implementations§
impl RefUnwindSafe for YearWeek
impl Send for YearWeek
impl Sync for YearWeek
impl Unpin for YearWeek
impl UnwindSafe for YearWeek
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more