pub struct YearMonth { /* private fields */ }
Expand description
A proleptic-Gregorian date consisting of a year and a month, with no time-zone or date information.
§Examples
use whatwg_datetime::{parse_month, YearMonth};
assert_eq!(parse_month("2011-11"), YearMonth::new_opt(2011, 11));
Implementations§
Source§impl YearMonth
impl YearMonth
Sourcepub fn new_opt(year: i32, month: u32) -> Option<Self>
pub fn new_opt(year: i32, month: u32) -> Option<Self>
Creates a new YearMonth
from a year and a month number.
This asserts that:
- the year is greater than 0
- that the month number is between 1 and 12, inclusive
§Examples
use whatwg_datetime::YearMonth;
assert!(YearMonth::new_opt(2011, 11).is_some());
assert!(YearMonth::new_opt(2011, 0).is_none()); // Month number must be at least 1
assert!(YearMonth::new_opt(0, 1).is_none()); // Year number must be greater than 0
Trait Implementations§
impl Copy for YearMonth
impl Eq for YearMonth
impl StructuralPartialEq for YearMonth
Auto Trait Implementations§
impl Freeze for YearMonth
impl RefUnwindSafe for YearMonth
impl Send for YearMonth
impl Sync for YearMonth
impl Unpin for YearMonth
impl UnwindSafe for YearMonth
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)