pub struct Date(_);
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.
Trait Implementations§
source§impl Ord for Date
impl Ord for Date
source§impl PartialEq<Date> for Date
impl PartialEq<Date> for Date
source§impl PartialOrd<Date> for Date
impl PartialOrd<Date> for Date
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