pub struct Date(/* private fields */);Expand description
A wrapper type for chrono::NaiveDate.
Implementations§
Source§impl Date
impl Date
Sourcepub fn try_new(year: i32, month: u32, day: u32) -> Result<Self, Error>
pub fn try_new(year: i32, month: u32, day: u32) -> Result<Self, Error>
Attempts to create a new instance.
Sourcepub fn num_days_from_epoch(&self) -> i32
pub fn num_days_from_epoch(&self) -> i32
Counts the days from the 1st of January 1970.
Sourcepub fn num_days_from(&self, other: Date) -> i32
pub fn num_days_from(&self, other: Date) -> i32
Counts the days from the other date.
Sourcepub fn format(&self, fmt: &str) -> String
pub fn format(&self, fmt: &str) -> String
Formats the date with the specified format string.
See format::strftime for the supported escape sequences.
Sourcepub fn duration_since(&self, earlier: Date) -> Duration
pub fn duration_since(&self, earlier: Date) -> Duration
Returns the amount of time elapsed from another date to this one, or zero duration if that date is later than this one.
Sourcepub fn span_between(&self, other: Date) -> Duration
pub fn span_between(&self, other: Date) -> Duration
Returns the duration of time between self and other.
Sourcepub fn quarter(&self) -> u32
pub fn quarter(&self) -> u32
Returns the quarter number starting from 1.
The return value ranges from 1 to 4.
Sourcepub fn month(&self) -> u32
pub fn month(&self) -> u32
Returns the month number starting from 1.
The return value ranges from 1 to 12.
Sourcepub fn day(&self) -> u32
pub fn day(&self) -> u32
Returns the day of month starting from 1.
The return value ranges from 1 to 31. (The last day of month differs by months.)
Sourcepub fn week(&self) -> u32
pub fn week(&self) -> u32
Returns the ISO week number starting from 1.
The return value ranges from 1 to 53. (The last week of year differs by years.)
Sourcepub fn day_of_year(&self) -> u32
pub fn day_of_year(&self) -> u32
Returns the day of year starting from 1.
The return value ranges from 1 to 366. (The last day of year differs by years.)
Sourcepub fn day_of_week(&self) -> u8
pub fn day_of_week(&self) -> u8
Returns the day of week starting from 0 (Sunday) to 6 (Saturday).
Sourcepub fn iso_day_of_week(&self) -> u8
pub fn iso_day_of_week(&self) -> u8
Returns the ISO day of week starting from 1 (Monday) to 7 (Sunday).
Sourcepub fn is_leap_year(&self) -> bool
pub fn is_leap_year(&self) -> bool
Returns true if the current year is a leap year.
Sourcepub fn is_weekend(&self) -> bool
pub fn is_weekend(&self) -> bool
Returns true if the current day is weekend.
Sourcepub fn days_in_current_year(&self) -> u32
pub fn days_in_current_year(&self) -> u32
Returns the number of days in the current year.
Sourcepub fn days_in_current_month(&self) -> u32
pub fn days_in_current_month(&self) -> u32
Returns the number of days in the current month.
Sourcepub fn start_of_current_year(&self) -> Self
pub fn start_of_current_year(&self) -> Self
Returns the start of the current year.
Sourcepub fn end_of_current_year(&self) -> Self
pub fn end_of_current_year(&self) -> Self
Returns the end of the current year.
Sourcepub fn start_of_next_year(&self) -> Self
pub fn start_of_next_year(&self) -> Self
Returns the start of the next year.
Sourcepub fn start_of_current_quarter(&self) -> Self
pub fn start_of_current_quarter(&self) -> Self
Returns the start of the current quarter.
Sourcepub fn end_of_current_quarter(&self) -> Self
pub fn end_of_current_quarter(&self) -> Self
Returns the end of the current quarter.
Sourcepub fn start_of_current_month(&self) -> Self
pub fn start_of_current_month(&self) -> Self
Returns the start of the current month.
Sourcepub fn end_of_current_month(&self) -> Self
pub fn end_of_current_month(&self) -> Self
Returns the end of the current month.
Sourcepub fn start_of_next_month(&self) -> Self
pub fn start_of_next_month(&self) -> Self
Returns the start of the next month.
Sourcepub fn checked_add_months(self, months: u32) -> Option<Self>
pub fn checked_add_months(self, months: u32) -> Option<Self>
Adds a duration in months to the date.
Returns None if the resulting date would be out of range.
Sourcepub fn checked_sub_months(self, months: u32) -> Option<Self>
pub fn checked_sub_months(self, months: u32) -> Option<Self>
Subtracts a duration in months from the date.
Returns None if the resulting date would be out of range.
Sourcepub fn checked_add_days(self, days: u32) -> Option<Self>
pub fn checked_add_days(self, days: u32) -> Option<Self>
Adds a duration in days to the date.
Returns None if the resulting date would be out of range.
Sourcepub fn checked_sub_days(self, days: u32) -> Option<Self>
pub fn checked_sub_days(self, days: u32) -> Option<Self>
Subtracts a duration in days from the date.
Returns None if the resulting date would be out of range.
Sourcepub fn days_in_year(year: i32) -> u32
pub fn days_in_year(year: i32) -> u32
Returns the number of days in the year.
Sourcepub fn days_in_month(year: i32, month: u32) -> u32
pub fn days_in_month(year: i32, month: u32) -> u32
Returns the number of days in the month.
Trait Implementations§
Source§impl AddAssign<Duration> for Date
impl AddAssign<Duration> for Date
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+= operation. Read moreSource§impl<'de> Deserialize<'de> for Date
impl<'de> Deserialize<'de> for Date
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'a> From<Date> for FluentValue<'a>
Available on crate feature i18n only.
impl<'a> From<Date> for FluentValue<'a>
i18n only.Source§impl Ord for Date
impl Ord for Date
Source§impl PartialOrd for Date
impl PartialOrd for Date
Source§impl SubAssign<Duration> for Date
impl SubAssign<Duration> for Date
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-= operation. Read moreimpl Copy for Date
impl Eq for Date
impl StructuralPartialEq for Date
Auto Trait Implementations§
impl Freeze for Date
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnwindSafe for Date
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.