pub struct Year(pub i64);
Expand description
A single year.
This is just a wrapper around i64
that performs year-related tests.
Tuple Fields§
§0: i64
Implementations§
Source§impl Year
impl Year
Sourcepub fn is_leap_year(self) -> bool
pub fn is_leap_year(self) -> bool
Returns whether this year is a leap year.
§Examples
use datetime::Year;
assert_eq!(Year(2000).is_leap_year(), true);
assert_eq!(Year(1900).is_leap_year(), false);
Sourcepub fn months<S: MonthSpan>(self, span: S) -> YearMonths
pub fn months<S: MonthSpan>(self, span: S) -> YearMonths
Returns an iterator over a continuous span of months in this year, returning year-month pairs.
This method takes one argument that can be of four different types, depending on the months you wish to iterate over:
- The
RangeFull
type (such as..
), which iterates over every month; - The
RangeFrom
type (such asApril ..
), which iterates over the months starting from the month given; - The
RangeTo
type (such as.. June
), which iterates over the months stopping at but not including the month given; - The
Range
type (such asApril .. June
), which iterates over the months starting from the left one and stopping at but not including the right one.
§Examples
use datetime::Year;
use datetime::Month::{April, June};
let year = Year(1999);
assert_eq!(year.months(..).count(), 12);
assert_eq!(year.months(April ..).count(), 9);
assert_eq!(year.months(April .. June).count(), 2);
assert_eq!(year.months(.. June).count(), 5);
Trait Implementations§
impl Copy for Year
impl StructuralPartialEq for Year
Auto Trait Implementations§
impl Freeze for Year
impl RefUnwindSafe for Year
impl Send for Year
impl Sync for Year
impl Unpin for Year
impl UnwindSafe for Year
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