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

icalendar_duration::parse.

Trait Implementations

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.

The resulting type after applying the + operator.

Performs the + operation. Read more

Panics

Panics if the resulting time does not exist in the datetime’s timezone.

The resulting type after applying the + operator.

The resulting type after applying the + operator.

Performs the + operation. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Performs the *= operation. Read more

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.

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.