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§
impl Copy for YearWeek
impl Eq for YearWeek
impl StructuralPartialEq for YearWeek
Auto Trait Implementations§
impl Freeze for YearWeek
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