Struct icalendar_duration::Rfc5545Duration
source · [−]pub struct Rfc5545Duration { /* private fields */ }
Expand description
The Duration specified in RFC554.
This has a few quirks that ultimately, make it incompatible with the Duration classes from both Chrono and the stdlib. The main difference is how DST transition and leap seconds are handled.
From Section 3.3.6:
The duration of a week or a day depends on its position in the calendar. In the case of discontinuities in the time scale, such as the change from standard time to daylight time and back, the computation of the exact duration requires the subtraction or addition of the change of duration of the discontinuity. Leap seconds MUST NOT be considered when computing an exact duration. When computing an exact duration, the greatest order time components MUST be added first, that is, the number of days MUST be added first, followed by the number of hours, number of minutes, and number of seconds.
This will usually behave rather intuitively for users. For an event that occurs at 16:00hs on the Monday after daylight saving, an alarm set 1 day before will trigger at 16hs, even though this is technically 25 (or 23) hours before the event.
Caveats
The specification indicates that numerical values are “one or more digits”. Technically,
setting an alarm one million years before an event is perfectly valid. However, modelling this
would require arbitrary precision numbers or using absurdly large sized integers. These
scenarios are valid but unrealistic, and are deliberately not supported in the interest of
better performance. Any 1*DIGIT
is restricted to an u16.
Parsing and re-encoding a duration will sometimes yield different results. In particular the
+
sign is always dropped (it is the implicit default) and units with value 0
are dropped.
E.g.: -P0DT1H
will become -PT1H
, and +PT1H
will become PT1H
. These are equivalent.
See also
Trait Implementations
sourceimpl Add<Rfc5545Duration> for DatePerhapsTime
impl Add<Rfc5545Duration> for DatePerhapsTime
Adds a duration to DatePerhapsTime
.
A DatePerhapsTime::Date
is equivalent to one with time 00:00:00
. From rfc5545,
section-3.8.6.3:
Alarms specified in an event or to-do that is defined in terms of a DATE value type will be triggered relative to 00:00:00 of the user’s configured time zone on the specified date, or relative to 00:00:00 UTC on the specified date if no configured time zone can be found for the user.
type Output = CalendarDateTime
type Output = CalendarDateTime
The resulting type after applying the +
operator.
sourcefn add(self, rhs: Rfc5545Duration) -> Self::Output
fn add(self, rhs: Rfc5545Duration) -> Self::Output
Performs the +
operation. Read more
sourceimpl<Tz: TimeZone> Add<Rfc5545Duration> for DateTime<Tz>
impl<Tz: TimeZone> Add<Rfc5545Duration> for DateTime<Tz>
sourceimpl Add<Rfc5545Duration> for NaiveDateTime
impl Add<Rfc5545Duration> for NaiveDateTime
type Output = NaiveDateTime
type Output = NaiveDateTime
The resulting type after applying the +
operator.
sourcefn add(self, rhs: Rfc5545Duration) -> Self::Output
fn add(self, rhs: Rfc5545Duration) -> Self::Output
Performs the +
operation. Read more
sourceimpl Debug for Rfc5545Duration
impl Debug for Rfc5545Duration
sourceimpl Default for Rfc5545Duration
impl Default for Rfc5545Duration
sourcefn default() -> Rfc5545Duration
fn default() -> Rfc5545Duration
Returns the “default value” for a type. Read more
sourceimpl Display for Rfc5545Duration
impl Display for Rfc5545Duration
sourceimpl MulAssign<Sign> for Rfc5545Duration
impl MulAssign<Sign> for Rfc5545Duration
sourcefn mul_assign(&mut self, rhs: Sign)
fn mul_assign(&mut self, rhs: Sign)
Performs the *=
operation. Read more
sourceimpl Neg for Rfc5545Duration
impl Neg for Rfc5545Duration
Changes the sign from positive to negative and vice versa.
Usage of this function is discouraged, since it creates a copy of the entire struct.
sourceimpl PartialEq<Rfc5545Duration> for Rfc5545Duration
impl PartialEq<Rfc5545Duration> for Rfc5545Duration
sourcefn eq(&self, other: &Rfc5545Duration) -> bool
fn eq(&self, other: &Rfc5545Duration) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl<Tz: TimeZone> Sub<Rfc5545Duration> for DateTime<Tz>
impl<Tz: TimeZone> Sub<Rfc5545Duration> for DateTime<Tz>
sourceimpl Sub<Rfc5545Duration> for NaiveDateTime
impl Sub<Rfc5545Duration> for NaiveDateTime
type Output = NaiveDateTime
type Output = NaiveDateTime
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: Rfc5545Duration) -> Self::Output
fn sub(self, rhs: Rfc5545Duration) -> Self::Output
Performs the -
operation. Read more
impl Eq for Rfc5545Duration
impl StructuralEq for Rfc5545Duration
impl StructuralPartialEq for Rfc5545Duration
Auto Trait Implementations
impl RefUnwindSafe for Rfc5545Duration
impl Send for Rfc5545Duration
impl Sync for Rfc5545Duration
impl Unpin for Rfc5545Duration
impl UnwindSafe for Rfc5545Duration
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more