pub struct MonthTuple { /* private fields */ }
Expand description
A container for a month of a specific year.
NOTE: MonthTuple’s m
field is one-based (one represents January) as of version 2.0.0.
Only handles values between Jan 0000 and Dec 9999 (inclusive).
Implementations§
Source§impl MonthTuple
impl MonthTuple
Sourcepub fn new(y: u16, m: u8) -> Result<MonthTuple, String>
pub fn new(y: u16, m: u8) -> Result<MonthTuple, String>
Produces a new MonthTuple.
Only accepts a valid month value (1 <= m <= 12
).
Only accepts a valid year value (0 <= y <= 9999
).
Sourcepub fn this_month() -> MonthTuple
pub fn this_month() -> MonthTuple
Returns a MonthTuple
of the current month according to the system clock.
pub fn get_year(self) -> u16
Sourcepub fn get_month(self) -> u8
pub fn get_month(self) -> u8
Retrieves the month component of the tuple.
Note this month is ONE-BASED (one represents January).
Sourcepub fn next_month(self) -> MonthTuple
pub fn next_month(self) -> MonthTuple
Gets a MonthTuple representing the month immediately following the current one. Will not go past Dec 9999.
Sourcepub fn previous_month(self) -> MonthTuple
pub fn previous_month(self) -> MonthTuple
Gets a MonthTuple representing the month immediately preceding the current one. Will not go past Jan 0000.
Sourcepub fn add_months(&mut self, months: u32)
pub fn add_months(&mut self, months: u32)
Adds a number of months to a MonthTuple.
Sourcepub fn subtract_months(&mut self, months: u32)
pub fn subtract_months(&mut self, months: u32)
Subtracts a number of months from a MonthTuple.
Sourcepub fn subtract_years(&mut self, years: u16)
pub fn subtract_years(&mut self, years: u16)
Subtracts a number of years from a MonthTuple.
Sourcepub fn to_readable_string(self) -> String
pub fn to_readable_string(self) -> String
Trait Implementations§
Source§impl Clone for MonthTuple
impl Clone for MonthTuple
Source§fn clone(&self) -> MonthTuple
fn clone(&self) -> MonthTuple
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more