pub struct Date(/* private fields */);Implementations§
Source§impl Date
impl Date
pub const MIN: Self
pub fn into_iso_string(self) -> String
pub fn weekday(self) -> Weekday
pub fn month(self) -> Month
Sourcepub fn day_of_month(self) -> DayOfMonth
pub fn day_of_month(self) -> DayOfMonth
Provides the day of month for this dates
§Panics
Panics when DayOfMonth is outside of a valid DayOfMonth value, which should never happen.
pub fn year(self) -> Year
pub fn day(self) -> u32
pub fn add_interval_days(self, value: Interval) -> Date
pub fn add_days(self, value: usize) -> Date
pub fn sub_days(self, value: usize) -> Date
pub const fn from_ymd_opt(year: Year, month: u32, day: u32) -> Option<Date>
pub fn day_after(self) -> Date
pub fn next_month(self) -> Date
pub fn first_of_next_month(self) -> Self
pub fn first_of_month(self) -> Self
pub fn first_of_year(self) -> Self
pub fn with_day(self, value: DayOfMonth) -> Option<Date>
pub fn is_valid_date_str(value: &str) -> bool
Sourcepub fn from_str_unchecked(value: &str) -> Date
pub fn from_str_unchecked(value: &str) -> Date
Converts the given string which is expected to be in ISO format (YYYY-mm-dd) into a Date.
§Panics
If the given &str is not in the valid format
Sourcepub fn days_between(self, other: Date) -> usize
pub fn days_between(self, other: Date) -> usize
Returns the absolute number of days between two dates
Sourcepub fn signed_days_from(self, reference: Date) -> i64
pub fn signed_days_from(self, reference: Date) -> i64
Returns signed difference in days (positive = self is in future, negative = self is in past)
Sourcepub fn next_business_day(self) -> Self
pub fn next_business_day(self) -> Self
Get the next business day (Monday-Friday) after this date
pub fn latest_sunday(self) -> Self
pub fn next_sunday(self) -> Self
pub fn next_saturday(self) -> Self
pub fn soonest_saturday(self) -> Self
Sourcepub fn next_monday(self) -> Self
pub fn next_monday(self) -> Self
Get the next Monday after this date (or next Monday if today is Monday)
Sourcepub fn add_months(self, months: impl Into<u32>) -> Self
pub fn add_months(self, months: impl Into<u32>) -> Self
Add the specified number of months to this date
Sourcepub fn sub_years(self, years: u32) -> Self
pub fn sub_years(self, years: u32) -> Self
Subtract the specified number of years from this date
Sourcepub fn sub_months(self, months: u32) -> Self
pub fn sub_months(self, months: u32) -> Self
Subtract the specified number of months from this date.
Sourcepub fn last_weekday(self, weekday: Weekday) -> Self
pub fn last_weekday(self, weekday: Weekday) -> Self
Returns the most recent occurrence of the given weekday. If today is that weekday, returns the previous occurrence (not today).
Sourcepub fn next_weekday(self, weekday: Weekday) -> Self
pub fn next_weekday(self, weekday: Weekday) -> Self
Returns the next occurrence of the given weekday. If today is that weekday, returns the next occurrence (not today).
Sourcepub fn last_day_of_month(self) -> Self
pub fn last_day_of_month(self) -> Self
Returns the last day of the current month.
Sourcepub fn last_day_of_next_month(self) -> Self
pub fn last_day_of_next_month(self) -> Self
Returns the last day of the next month.
Sourcepub fn next_january_first(self) -> Self
pub fn next_january_first(self) -> Self
Get January 1st of the next year
Sourcepub fn january_first(year: Year) -> Option<Self>
pub fn january_first(year: Year) -> Option<Self>
January first of this year.