jiff::span

Function clamp_relative_span

Source
fn clamp_relative_span(
    relative: &Relative<'_>,
    span: Span,
    unit: Unit,
    amount: ri64<{ _ }, { _ }>,
) -> Result<(ri128<{ i128::MIN }, { i128::MAX }>, ri128<{ i128::MIN }, { i128::MAX }>), Error>
Expand description

Returns the nanosecond timestamps of relative + span and relative + {amount of unit} + span.

This is useful for determining the actual length, in nanoseconds, of some unit amount (usually a single unit). Usually, this is called with a span whose units lower than unit are zeroed out and with an amount that is -1 or 1 or 0. So for example, if unit were Unit::Day, then you’d get back two nanosecond timestamps relative to the relative datetime given that start exactly “one day” apart. (Which might be different than 24 hours, depending on the time zone.)

§Errors

This returns an error if adding the units overflows, or if doing the span arithmetic on relative overflows.