pub(crate) fn fractional_time_to_span(
unit: Unit,
value: ri64<{ _ }, { _ }>,
fraction: ri32<0, { _ }>,
span: Span,
) -> Result<Span, Error>
Expand description
This routine returns a span based on the given with fractional time applied to it.
For example, given a span like P1dT1.5h
, the unit
would be
Unit::Hour
, the value
would be 1
and the fraction
would be
500_000_000
. The span given would just be 1d
. The span returned would
be P1dT1h30m
.
Note that fraction
can be a fractional hour, minute, second, millisecond
or microsecond (even though its type suggests its only a fraction of a
second). When milliseconds or microseconds, the given fraction has any
sub-nanosecond precision truncated.
§Errors
This can error if the resulting units would be too large for the limits on
a span
. This also errors if unit
is not Hour
, Minute
, Second
,
Millisecond
or Microsecond
.