Struct date_time::date_tuple::DateTuple
source · pub struct DateTuple { /* private fields */ }
Expand description
Holds a specific date by year, month, and day.
Handles values from 01 Jan 0000 to 31 Dec 9999.
Implementations§
source§impl DateTuple
impl DateTuple
sourcepub fn new(y: u16, m: u8, d: u8) -> Result<DateTuple, String>
pub fn new(y: u16, m: u8, d: u8) -> Result<DateTuple, String>
Takes a year, month, and day and converts them into a DateTuple.
Will not overlap - the date entered must be valid without further calculation.
sourcepub fn today() -> DateTuple
pub fn today() -> DateTuple
Returns a DateTuple
of the current date according to the system clock.
pub fn get_year(&self) -> u16
pub fn get_month(&self) -> u8
pub fn get_date(&self) -> u8
sourcepub fn next_date(self) -> DateTuple
pub fn next_date(self) -> DateTuple
Gets a DateTuple representing the date immediately following the current one. Will not go past Dec 9999.
sourcepub fn previous_date(self) -> DateTuple
pub fn previous_date(self) -> DateTuple
Gets a DateTuple representing the date immediately preceding the current one. Will not go past 1 Jan 0000.
sourcepub fn subtract_days(&mut self, days: u32)
pub fn subtract_days(&mut self, days: u32)
Subtracts a number of days from a DateTuple.
sourcepub fn add_months(&mut self, months: u32)
pub fn add_months(&mut self, months: u32)
Adds a number of months to a DateTuple.
If the day of month is beyond the last date in the resulting month, the day of month will be set to the last day of that month.
sourcepub fn subtract_months(&mut self, months: u32)
pub fn subtract_months(&mut self, months: u32)
Subtracts a number of months from a DateTuple.
If the day of month is beyond the last date in the resulting month, the day of month will be set to the last day of that month.
sourcepub fn add_years(&mut self, years: u16)
pub fn add_years(&mut self, years: u16)
Adds a number of years to a DateTuple.
If the date is set to Feb 29 and the resulting year is not a leap year, it will be changed to Feb 28.
sourcepub fn subtract_years(&mut self, years: u16)
pub fn subtract_years(&mut self, years: u16)
Subtracts a number of years from a DateTuple.
If the date is set to Feb 29 and the resulting year is not a leap year, it will be changed to Feb 28.
sourcepub fn to_readable_string(&self) -> String
pub fn to_readable_string(&self) -> String
Trait Implementations§
source§impl From<DateTuple> for MonthTuple
impl From<DateTuple> for MonthTuple
source§impl Ord for DateTuple
impl Ord for DateTuple
source§impl PartialOrd<DateTuple> for DateTuple
impl PartialOrd<DateTuple> for DateTuple
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more