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>
Add Days to NaiveDateTime.
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_add_days to get an Option instead.
Source§impl Add<Days> for NaiveDate
Add Days to 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
Add Days to 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 PartialOrd for Days
impl PartialOrd for Days
Source§impl<Tz: TimeZone> Sub<Days> for DateTime<Tz>
Subtract Days from DateTime.
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
Subtract Days from 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
Subtract Days from 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.