pub struct Days(/* private fields */);
Expand description
A duration in calendar days.
This is useful because when using TimeDelta
it is possible that adding TimeDelta::days(1)
doesn’t increment the day value as expected due to it being a fixed number of seconds. This
difference applies only when dealing with DateTime<TimeZone>
data types and in other cases
TimeDelta::days(n)
and Days::new(n)
are equivalent.
Implementations§
Trait Implementations§
source§impl<Tz: TimeZone> Add<Days> for DateTime<Tz>
impl<Tz: TimeZone> Add<Days> for DateTime<Tz>
Add Days
to NaiveDateTime
.
§Panics
Panics if:
- The resulting date would be out of range.
- The local time at the resulting date does not exist or is ambiguous, for example during a daylight saving time transition.
Strongly consider using DateTime<Tz>::checked_sub_days
to get an Option
instead.
source§impl Add<Days> for NaiveDate
impl Add<Days> for NaiveDate
Add Days
to NaiveDate
.
§Panics
Panics if the resulting date would be out of range.
Consider using NaiveDate::checked_add_days
to get an Option
instead.
source§impl Add<Days> for NaiveDateTime
impl Add<Days> for NaiveDateTime
Add Days
to NaiveDateTime
.
§Panics
Panics if the resulting date would be out of range.
Consider using checked_add_days
to get an Option
instead.
source§impl Ord for Days
impl Ord for Days
source§impl PartialEq for Days
impl PartialEq for Days
source§impl PartialOrd for Days
impl PartialOrd for Days
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 moresource§impl<Tz: TimeZone> Sub<Days> for DateTime<Tz>
impl<Tz: TimeZone> Sub<Days> for DateTime<Tz>
Subtract Days
from DateTime
.
§Panics
Panics if:
- The resulting date would be out of range.
- The local time at the resulting date does not exist or is ambiguous, for example during a daylight saving time transition.
Strongly consider using DateTime<Tz>::checked_sub_days
to get an Option
instead.
source§impl Sub<Days> for NaiveDate
impl Sub<Days> for NaiveDate
Subtract Days
from NaiveDate
.
§Panics
Panics if the resulting date would be out of range.
Consider using NaiveDate::checked_sub_days
to get an Option
instead.
source§impl Sub<Days> for NaiveDateTime
impl Sub<Days> for NaiveDateTime
Subtract Days
from NaiveDateTime
.
§Panics
Panics if the resulting date would be out of range.
Consider using checked_sub_days
to get an Option
instead.