pub struct Date(/* private fields */);Expand description
Represents a date.
Implementations§
Source§impl Date
impl Date
pub const UNIX_EPOCH: Self
Sourcepub const fn create(year: u32, month: Month, day: u8) -> Result<Self, DateError>
pub const fn create(year: u32, month: Month, day: u8) -> Result<Self, DateError>
Create a date based on a year, a month, and a day.
Sourcepub fn to_string_iso8601_extended(self) -> String
pub fn to_string_iso8601_extended(self) -> String
String representation for the current date, e.g. “2021-01-16”.
Sourcepub fn to_string_iso8601_basic(self) -> String
pub fn to_string_iso8601_basic(self) -> String
String representation for the current date, e.g. “20210116”.
Sourcepub fn to_string_american(self) -> String
pub fn to_string_american(self) -> String
String representation for the current date, e.g. “01/16/2021”.
Sourcepub fn add_months(self, m: i32) -> Self
pub fn add_months(self, m: i32) -> Self
Add some number of months to a date. This returns the date with the last day of the month in the case where the actual date would be invalid, e.g. adding a month to Jan 31 results in Feb 28 or Feb 29 depending on whether it’s a leap year or not.
Sourcepub fn add_years(self, y: i32) -> Self
pub fn add_years(self, y: i32) -> Self
Add some number of years to a date. If the returned day would not exist (e.g. Feb 28), the last day of the target month is returned.
Sourcepub fn day_of_week(self) -> DayOfWeek
pub fn day_of_week(self) -> DayOfWeek
The day of the week for this date.
Sourcepub fn of_days_since_epoch(d: i32) -> Self
pub fn of_days_since_epoch(d: i32) -> Self
The number of days since epoch (1970-01-01).
pub fn is_weekday(self) -> bool
pub fn is_weekend(self) -> bool
Sourcepub fn round_forward_to_business_day<F>(self, is_business_day: F) -> Self
pub fn round_forward_to_business_day<F>(self, is_business_day: F) -> Self
Rounds the date to the next value that satisfies is_business_day if it is not already a business day.
Sourcepub fn round_backward_to_business_day<F>(self, is_business_day: F) -> Self
pub fn round_backward_to_business_day<F>(self, is_business_day: F) -> Self
Rounds the date to the previous value that satisfies is_business_day if it is not already a business day.
Sourcepub fn add_business_days_rounding_backward<F>(
self,
days: i64,
is_business_day: F,
) -> Self
pub fn add_business_days_rounding_backward<F>( self, days: i64, is_business_day: F, ) -> Self
First rounds the given date backward to the previous business day as defined by F if it does not already satisfy it. Then advances by the given number of business days which may be negative.
Sourcepub fn add_business_days_rounding_forward<F>(
self,
days: i64,
is_business_day: F,
) -> Self
pub fn add_business_days_rounding_forward<F>( self, days: i64, is_business_day: F, ) -> Self
First rounds the given date forward to the next business day as defined by F if it does not already satisfy it. Then advances by the given number of business days which may be negative.
Source§impl Date
impl Date
Sourcepub fn dates_between(lo: Self, up: Self) -> DatesBetween ⓘ
pub fn dates_between(lo: Self, up: Self) -> DatesBetween ⓘ
Lists all the dates between two dates (inclusive).
Sourcepub fn dates_until(self, up: Self) -> DatesBetween ⓘ
pub fn dates_until(self, up: Self) -> DatesBetween ⓘ
Lists all the dates from the self date until up (inclusive).
Source§impl Date
impl Date
Sourcepub fn weekdays_between(lo: Self, up: Self) -> WeekdaysBetween ⓘ
pub fn weekdays_between(lo: Self, up: Self) -> WeekdaysBetween ⓘ
Lists all the weekdays between two dates (inclusive).
Sourcepub fn weekdays_until(self, up: Self) -> WeekdaysBetween ⓘ
pub fn weekdays_until(self, up: Self) -> WeekdaysBetween ⓘ
Lists all the weekdays from the self date until up (inclusive).
Source§impl Date
impl Date
Sourcepub fn business_days_between<F>(
lo: Self,
up: Self,
is_business_day: F,
) -> BusinessDaysBetween<F> ⓘ
pub fn business_days_between<F>( lo: Self, up: Self, is_business_day: F, ) -> BusinessDaysBetween<F> ⓘ
Lists all the business days between two dates (inclusive).
Sourcepub fn business_days_until<F>(
self,
up: Self,
is_business_day: F,
) -> BusinessDaysBetween<F> ⓘ
pub fn business_days_until<F>( self, up: Self, is_business_day: F, ) -> BusinessDaysBetween<F> ⓘ
Lists all the business days from the self date until up (inclusive).
Trait Implementations§
Source§impl AddAssign<i32> for Date
impl AddAssign<i32> for Date
Source§fn add_assign(&mut self, other: i32)
fn add_assign(&mut self, other: i32)
+= operation. Read moreSource§impl BinProtRead for Date
impl BinProtRead for Date
Source§impl BinProtWrite for Date
impl BinProtWrite for Date
Source§impl<'de> Deserialize<'de> for Date
impl<'de> Deserialize<'de> for Date
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Ord for Date
impl Ord for Date
Source§impl PartialOrd for Date
impl PartialOrd for Date
Source§impl SubAssign<i32> for Date
impl SubAssign<i32> for Date
Source§fn sub_assign(&mut self, other: i32)
fn sub_assign(&mut self, other: i32)
-= operation. Read moreimpl Copy for Date
impl Eq for Date
impl StructuralPartialEq for Date
impl UseToString for Date
sexp only.