unit_start_and_end

Function unit_start_and_end 

Source
fn unit_start_and_end(
    relative: &Relative<'_>,
    span: Span,
    unit: Unit,
    amount: i64,
) -> Result<(SignedDuration, SignedDuration), 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.