pub struct Date(/* private fields */);
Expand description
Representation of a date in the local time zone.
Implementations§
Source§impl Date
impl Date
Sourcepub fn new(year: i32, month: u32, day: u32) -> Result<Self>
pub fn new(year: i32, month: u32, day: u32) -> Result<Self>
Create a Date
out of a year, month, and day, returning a Result
.
§Errors
If one of the parameters is outside the legal range for a date, returns an
DateError::InvalidDate
.
Sourcepub fn parse(datespec: &str) -> Result<Self>
pub fn parse(datespec: &str) -> Result<Self>
Create a Date
object from the supplied date specification.
Legal specifications include “today” and “yesterday”, the days of the week “sunday” through “saturday”, and a date in the form “YYYY-MM-DD”. The days of the week result in the date representing the previous instance of that day (last Monday for “monday”, etc.).
§Errors
Return DateError::InvalidDaySpec
if the supplied spec is not valid.
Source§impl Date
impl Date
Sourcepub fn weekday_str(&self) -> &'static str
pub fn weekday_str(&self) -> &'static str
Return the day of the week as a string.
Source§impl Date
impl Date
Sourcepub fn month_start(&self) -> Date
pub fn month_start(&self) -> Date
Create a Date
object for the last day of the month.
Sourcepub fn week_start(&self) -> Date
pub fn week_start(&self) -> Date
Create a Date
object for the first day of the week.
Sourcepub fn year_start(&self) -> Date
pub fn year_start(&self) -> Date
Create a Date
object for the beginning of the year containing the date.