pub struct YearMonth {
pub year: Year,
pub month: Month,
}
Expand description
A month-year pair.
Fields§
§year: Year
§month: Month
Implementations§
Source§impl YearMonth
impl YearMonth
Sourcepub fn day_count(&self) -> i8
pub fn day_count(&self) -> i8
Returns the number of days in this month. This can be definitely known, as the paired year determines whether it’s a leap year, so there’s no chance of being caught out by February.
§Examples
use datetime::Year;
use datetime::Month::February;
assert_eq!(Year(2000).month(February).day_count(), 29);
assert_eq!(Year(1900).month(February).day_count(), 28);
Sourcepub fn days<S: DaySpan>(&self, span: S) -> MonthDays
pub fn days<S: DaySpan>(&self, span: S) -> MonthDays
Returns an iterator over a continuous span of days in this month,
returning LocalDate
values.
§Examples
use datetime::Year;
use datetime::Month::September;
let ym = Year(1999).month(September);
assert_eq!(ym.days(..).count(), 30);
assert_eq!(ym.days(10 ..).count(), 21);
assert_eq!(ym.days(10 .. 20).count(), 10);
assert_eq!(ym.days(.. 20).count(), 19);
Trait Implementations§
impl Copy 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